Operators

instanceof operator

Try the free JavaScript compiler

Tests instance membership using a custom Symbol.hasInstance method when present, otherwise ordinarily checking the constructor prototype chain for objects. It is not a universal cross-realm type test.

Formal Syntax & Structure

javascript syntaxjavascript
value instanceof Constructor

Parameters & Attributes

NameTypeDescription
valueAnyValue to test.
ConstructorObjectRight-hand operand with valid instance checking behavior.

Return Value

Boolean

Instance check.

Working Example

Example Snippetjavascript
function F(){}console.log(new F() instanceof F,{} instanceof F);
JavaScript Reference