JavaScriptの特別な値メモ
- undefined
- typeof undefined → "undefined"
- undefined === undefined → true
- undefined == null → true
- undefined == 0 → false
- undefined == false → false
- void x → undefined
- null
- typeof null → "object"
- null === null → true
- null == 0 → false
- null == false → false
- NaN
- typeof NaN → "number"
- NaN === NaN → false
- -NaN → NaN
- Infinity
- typeof Infinity → "number"
- Infinity === Infinity → true
- -Infinity === -Infinity → true
- Infinity === -Infinity → false
- Infinity - Infinity, 0*Infinity, Infinity/Infinity → NaN
- Infinity + 3, Infinity - 10, 2*Infinity, Infinity*Infinity → Infinity
- true, false
- false == 0 → true
- true == 1 → true
- true == 2 → false (真偽値と数値は、数値に変換して比較する)
このうち、undefined, NaN, Infinity には値を代入できてしまう!