Outline
The typeof
operator returns the data type of the parameter, but it has various 'gotchas'.
Things to be aware of:
typeof
recognizesNaN
as anumber
.typeof
recognizes any complex data types, like Arrays or Maps, as simplyobject
.typeof
also recognizesnull
as anobject
.- There are better ways to determine the types of complex data objects. For arrays, you can call
Array.isArray(object)
method. Other data types have similar methods for determining type.