Jump to content

JavaScript/Reserved words/typeof

From Wikibooks, open books for an open world
Previous: try Reserved words Next: var

The typeof keyword

[edit | edit source]

The typeof keyword is a unary operator that returns a string giving the type of the parametre.

Syntax

[edit | edit source]
  typeof[(]expression[)];

The operator returns six values, which are boolean, function, number, object, string, and undefined.

Examples

[edit | edit source]
  theArray = new Array();
  if (typeof(theArray) == 'object') {
    []
  }
Previous: try Reserved words Next: var