Opens in a new tab
A picture of Jeff Brigman
I CODE TODAY FOR
A BETTER TOMORROW

Glossary Term

Symbol.hasInstance

2 tags 1 category

The Symbol.hasInstance static data property represents the well-known symbol Symbol.hasInstance. The instanceof operator looks up this symbol on its right-hand operand for the method used to determine if the constructor object recognizes an object as its instance.

The instanceof operator uses the following algorithm to calculate the return value of object instanceof constructor:

1. If constructor has a Symbol.hasInstance method, then call it with object as the first argument and return the result, coerced to a boolean. Throw a TypeError if constructor is not an object, or if constructor[Symbol.hasInstance] is not one of null, undefined, or a function. 2. Otherwise, if constructor doesn’t have a Symbol.hasInstance method (constructor[Symbol.hasInstance] is null or undefined), then determine the result using the same algorithm as Function.prototype[Symbol.hasInstance](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/Symbol.hasInstance). Throw a TypeError if constructor is not a function.

Term Connections

Explore related terms connected by shared tags, shared categories, and relationship phrases. This map loads only when it comes into view.

Loading term connections…