Automatic type coercion – concatenating a string and a number doesn’t result in an error, the type of the other variable
is converted to the type of the other. Here’s an example:
If for example the result of an operator is not a number then we get NaN.
varx=2;//numberx=true;//booleanx="Im a string";//string
In the example above we changed the type of the variable x from number, to boolean and finally to a string. This is perfectly fine in
There are 7 falsy values:
Force conversion from a specific type to boolean. This will most likely be used in determinining whether a variable contains a truthy or falsy value.
!!5;//output: true;!!undefined;//output: false;
typeof operator allows you to determine the type currently represented by a variable. Here’s an example: