Type Checking in JavaScript

At first, type checking may seem like a straightforward concept. A value can either be an object, a function, an array, a number, a string, a boolean, null, or undefined. JavaScript has the typeof operator which returns a string indicating the type of the operand.

typeof 5 === 'number' // true 

Easy as pie, right? Unfortunately, typeof is not as reliable as you might think.

What does the following equal?

typeof NaN 

If you …

Read Article