JavaScript/Reserved words/typeof

From Wikibooks, open books for an open world
Jump to: navigation, search
Previous: try Reserved words Next: var

The typeof keyword[edit]

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

Syntax[edit]

  typeof[(]expression[)];

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

Examples[edit]

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