/

HTML / CSS / JavaScript Tutorial

JavaScript Operator: instanceof

[this page | pdf | back links]

In JavaScript, the instanceof operator returns true if a specified object is an instance of the specified object type, otherwise returns false.

 

For example, suppose we have an array:

 

var x = ["a","b"];

 

Then (x instanceof Array) and (x instanceof Object) both return true (because x is an array and arrays are themselves objects, but (x instanceof String) returns false

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript Operators


Desktop view | Switch to Mobile