It’s also useful to know that NaN is a type of number and null is an object.
1234.5678 // Valid number 12.3e2 // 1230
Nothing really unexpected here except that there’s no int, float, double etc. Just number. Simple.
Strings are what you expect them to be. Any bunch of characters, enclosed in single or double quotes. Characters are escaped or given special meaning using a
\ followed by a character.
\" all work as expected.
Booleans are - wait for it - either
We all know BODMAS and the usual
% behaviour with numbers.
+works on strings as a concatenator
-can be used as a unary operator
--are all part of the language and work as expected
"5" == 5 // true 0 == "" // true 1 == true // true 0 == false // true null == 0 // false null == false // false null == true // false null == undefined // true NaN == NaN // false
The below conversions take place before the operator is evaluated.
Number vs Boolean
Number vs String
""is converted to a zero.
String and Boolean