A, logical operators
Logical operators for determining the logical connection between the variable or value.
example:
2 = 1 &&> 2 when the first value may be converted to true returns the second value; otherwise, it returns a first value;
2 || 0 => 2 when the first value may be converted to a value of true is returned; otherwise, it returns the second value;
As well as when we write the callback function, it is generally better to write:
function fn(callback){ return callback && callback() }
fn(function(){})
Second, the expression will be converted to false are:
- null;
- NaN;
- 0;
- Empty string ( '' || "" || ``);
- undefined;