Name

typeof — NN 3 IE J1 ECMA 1

Synopsis

The typeof operator. This unary operator returns one of six string descriptions of the data type of a value. Those returned types are:

  • boolean

  • function

  • number

  • object

  • string

  • undefined

The object type includes arrays, but the operator provides no further information about the type of object or array of the value.

Example

if (typeof someVar == "string") {
    ...
}

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.