DEV Community


Posted on


Getting started with Eloquent Javascript : Chapter one summary

“Below the surface of the machine, the program moves. Without effort, it expands and contracts. In great harmony, electrons scatter and regroup. The forms on the monitor are but ripples on the water. The essence stays invisibly below.”

— Master Yuan-Ma, The Book of Programming


If we deep dive into the computer's world , we are going to findout it's all Data in there , It always has been . So if something is not Data neither we can use it nor mention it within computers .It's important to remember here every Data is fundamentally same as they are all stored in long sequence of Bits .

so you must be thinking what are these let's talk about it .

What is Bits ?

Although we usually describe it as ones and zeros it can take any forms like high or low electrical charge , a strong or weak signal etc .

If any form of information can be reduced to a sequence of zeros and ones, It can be represented in Bits .

Fun Fact : Modern computers have more than 30 million bits in its volatile memory itself .

How can a human work with this ocean of bits without getting lost in them ?

The answer is Divide and Conquer . We group them according to their type so that they can represent particular pieces of information according to their role .

These chunks of Bits are also known as Values and they can be of different types like functions, text , number etc .

So how do we create those values and use it according to our requirement ?

All you have to do is call it ..or you can say invoke its name and voila , you will have it .

One thing we must keep in mind while using Values is, every one of them is getting stored somewhere in memory and that is memory is limited .

So if you are not needing them simultaneously there should not be any problems as values will disipate as soon as you stop needing them .

Different Types of Values


As you can guess from the name, values of this type are numeric values like 13,15,100 etc. As javascript uses a fixed number of bits i.e 64 bits to represent Numbers, there is a certain limit to the number of different numbers we can represent, although that limit is about 18 quintillion.

There is something important here to remember that not only whole numbers but also negative(like -13 or -20) and fractional numbers (like 5.2 or 2.99e8 ) are there too, to be represent by the same 64 bits pattern .

However calculations involving with fractional numbers are generally not precise like it's with whole numbers .

which lead us to the main thing that numbers do, that is arithamtic operations.

Arithmatic Operations
It basically take two numbers , perform some operations with the help of operator like '+' ,'-', '*' ,'/', '%'and return another number .

The order in which the operations are going to be executed is decided by Operator Precedence. Most of the time they follow the BODMAS rule generally .

for example : 100+10*45 = 550

You can always change the precendce by wrapping the operands in parantheses .

for example : (100+10)*45 = 4950

Fun Fact : There is a difference between modulo('%') and
remainder ('%').Remainder can be negative but modulo is
always positive.

Special Numbers
There are three special values are there too in javascript which are considered as numbers but don't behave a like a normal one .

They are iInfinity ,-Infinity and NaN ( stands for "not a number") .


After Number strings are the next common data types , which are mainly used to represent text . If we want anything to be perceived as strings, we must wrap them around in quotes .

It can be single quotes,double quotes or backticks .Take a look at below examples.

   `Down on the sea`
   "Lie on the ocean"
   'Float on the ocean'

Enter fullscreen mode Exit fullscreen mode

so you must be thinking why are using backticks ?

Because when required they can embed other values too .
let's have a look at below example

half of 100 is ${100 / 2} // "half of 100 is 50"

you can see when we write something inside ${}within a backtick, the results will be computed first before converting into a string.They are known as Template Literals .

Fun Fact : we can use '+' on strings which concatenates or glues them together .

Boolean Values

Javascript has a Boolean data type which only has just two values i.e true or false . It is very useful in controlling the program flow when using conditional statements like if..else .

console.log(3 > 2) // true
console.log(3 < 2) // false
console.log(NaN == NaN) // false

Enter fullscreen mode Exit fullscreen mode

Fun fact : NaN is only value in js that is not equal to itself.

Empty values

You may have known them as undefined or null . These values are only used in the absence of meaningful value .

Generally undefined means the variable or the memory location is not defined or instantiated but null however means lack of a value , however you can use them interchangeable as it does not matter most of the time .


Operators are normally special symbols which are used to perform operations on values or variables a.k.a Operands . But not all operators are symbols some are written as words too .

for example type of operator . It is also known as unary operator as it only operates on one value .

for example :

console.log(typeof 6 ) // Number

There are also Binary and Ternary operators too , which operates on two or three operands respectively .

Binary operators examples :

console.log (6 + 3) // 9

Ternary operator syntax :

(conditon) ? statement-if-true: statement-if-false.


So we have discused briefly about various types of javascript values and operators that can transform them . But if you want to know more about them you can read it from here.

Thank you ..

Top comments (0)

Visualizing Promises and Async/Await 🤯

async await

☝️ Check out this all-time classic DEV post