About null, undefined, NaN

September 15, 2017

Type

typeof null
//=> "object"

typeof undefined
//=> "undefined"

typeof NaN
//=> "number"

undefined is undefined, null is an obejct standing for nothing, while undefined

Expressions

null + ''
//=> "null"

undefined + ''
//=> "undefined"

// NaN -> NaN
NaN + ''
//=> "NaN"

NaN + 1
//=> NaN

NaN + 3
//=> NaN

// null + int -> int
null + 3
//=> 3

// NaN + undefined||null -> NaN
null + NaN
//=> NaN

undefined + NaN
//=> NaN

undefined + 3
//=> NaN

// WTF
null + undefined
//=> NaN

Tagged withjavascript

Questions, Comments, Suggestions? Open an Issue