It is based on the fact that there is no need to provide information about the type of variable that we want to create.
Variables can hold diferent types of values because just like i said its figured out during execution phase.
It should also be remembered that there in other languages may be the opposite of Dynamic Typing - Static Typing.
An example of such language is Java.
In the first line, we see how the Java engine would react to assigning to an integer variable a string.
It is a type of data that represents a single value. Type of data that is not an object.
Let's start with the first one.
As you remember, we have already come across this. It represents lack of existence but you shuld not set a variable to this. If you want to set something to equal nothing you should use a second Primitive Type: null.
It also represents lack of existence but it's used by developers when they want to set for example a variable to equal nothing.
It is represented by two values: true / false.
Unlike other programming languages, there is only one number type and it's a Floating Point Number. It means that there are always some decimals. You will see in the future that it can make math a little bit weird.
It is a sequence of characters placed in " " or ' '.
At the moment, I will leave it as it is, but it is good to know that there is such a type.
However, it would be very troublesome and not very intuitive. After all, we have all been taught mathematics since the early years and we know that if we want to add two numbers, we do it obviously: 1 + 5, not add(1.5).
To get to know all kinds of operators, please visit this link. There, you will find a detailed breakdown of operators and simple examples.
When you are finished, and i strongly recommend since it is really well explained we will dive into two topics related to operators.
It tells us which operator function gets called first. Functions (remember operators are just a special type of a function) are called in order of precedence. A higher precedence always wins.
It tells us in what order operator functions get called in: left-to-right or right-to-left. It happens when functions have the same operator precedence.
Ok let's check this example.
It shows a value of precedence and an associativity. So when it comes to Operator Precedence you must remember that the operator with higher value will always win.
Together with the Precedent Operator goes associativity. As you can see in the table above, you can choose either left-to-right or right-to-left. To better understand when is it useful to us, I will use an example.
Do you have an idea what will be the result of each console.log?
Why is it like that ? The answer is Associativity.
In the a = b = c statement, we see two identical operators. Since the operators are same it means they have the same Operator Precedence value. Let's take a look at the table now. When we find equal symbol, we see its precedence is equal to 3 and its associativity is right-to-left.
If b is equal 4 now and last part of the statement is a = b, a will also equal to 4. That's why the result of all three console.log methods will be 4.
I will talk about Coercion and a little bit more about Comparison Operators.