(currently at: http://javascript.info/function-expressions-arrows)
You don’t need to define script type in the html <script> tags anymore.
‘+’ concatenates if at least one variable is a string whereas other mathematical operations convert variables to numbers.
PHP treats “0” as false, whereas Boolean(“0″) or (” “) in JS is true.
** is the exponentiation operator (2**3 = 8, 8**(1/3)=2)
++/– the prefix form changes assigned value, and postfix does not.
let counter = 1; let a = ++counter; // (*) alert(a); // 2
let counter = 1; let a = counter++; // (*) changed ++counter to counter++ alert(a); // 1
, operator evaluates serveral expressions and outputs the last result.
“a” > “A” == True because string comparison uses Unicode.
null == undefined // True (special rule), even though null becomes 0 and undefined Nan when converted to numbers.
alert( null > 0 ); // (1) false alert( null == 0 ); // (2) false alert( null >= 0 ); // (3) true
why: comparisons (>=, >) converts null to number (0), and equality (==) for null only equals undefined (and vice versa) but nothing else.
use ternary ‘?’ to return values, and ‘if’ to execute branches of code.
|| returns the last operand if no true operand is found.
AND returns the first falsy value or the last value if none were found.
The precedence of AND && operator is higher than OR ||.
A double NOT !! is sometimes used for converting a value to boolean type.
alert( !!"non-empty string" ); // true alert( !!null ); // false