2018-07-24 06:17:07 +00:00
|
|
|
// Nothing is weird here, if you think a little bit more about it
|
2020-10-15 17:29:27 +00:00
|
|
|
// but it seems to be
|
2017-06-11 14:00:29 +00:00
|
|
|
|
|
|
|
// Null is an Object
|
|
|
|
typeof null // => 'object'
|
|
|
|
|
2021-05-31 18:35:28 +00:00
|
|
|
// Weird decimal calculation
|
|
|
|
0.1 + 0.2 // -> 0.30000000000000004
|
|
|
|
|
2017-06-11 14:00:29 +00:00
|
|
|
// Despite this, null is not an instance of an Object
|
|
|
|
null instanceof Object // => false
|
|
|
|
|
|
|
|
// "string" is not an instance of String
|
|
|
|
"string" instanceof String
|
|
|
|
|
|
|
|
// NaN is a number
|
|
|
|
typeof NaN // -> 'Number'
|
|
|
|
|
|
|
|
// NaN is not considered equal to itself
|
|
|
|
NaN === NaN // -> false
|
|
|
|
|
|
|
|
// Array With No Keys == False
|
|
|
|
new Array() == false // -> true
|
|
|
|
|
|
|
|
// big integer numbers
|
|
|
|
9999999999999999 // -> 10000000000000000
|
|
|
|
|
2020-10-15 17:29:27 +00:00
|
|
|
//
|
2017-06-11 14:00:29 +00:00
|
|
|
[]+[] // -> ""
|
|
|
|
[]+{} // -> "[object Object]"
|
|
|
|
{}+[] // -> "{}+[]"
|
|
|
|
{}+{} // -> NaN
|
|
|
|
|
|
|
|
// Comparisons
|
|
|
|
3>2>1 // -> false
|
|
|
|
|
|
|
|
// Boolean arithmetic
|
|
|
|
true+true===2 // -> true
|
|
|
|
true-true===0 // -> true
|
|
|
|
true===1 // -> false
|
|
|
|
|
|
|
|
// Something really strange
|
|
|
|
(!+[]+[]+![]).length // -> 9
|
|
|
|
// because:
|
|
|
|
// +[] -> 0
|
|
|
|
// !+[] -> true
|
|
|
|
// !+[]+[] -> 'true'
|
|
|
|
// etc.
|
|
|
|
|