JavaScript/Reserved words/instanceof

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

The instanceof keyword[edit | edit source]

The instanceof keyword returns true, if the left-hand side of the operator corresponds to the class on the right-hand side.

Syntax[edit | edit source]

  object instanceof class

Examples[edit | edit source]

  theArray = new Array();
  if (theArray instanceof Array) {
    for (var i = 0; i < theArray.length; i++) {
      []
    }
  }
Previous: in Reserved words Next: int