jskatas.org Continuously Learn JavaScript. Your Way.

Symbol: Symbol.hasInstance method

Symbol.hasInstance can be used to override the result of instanceof.

hasInstance

WHEN defining the static method [Symbol.hasInstance] THEN the result is used with instanceof
class Square { static [Symbol.hasInstance](instance) { return true; } } assert.equal(Square instanceof Square, true);

Links

Description of `Symbol.hasInstance` on MDN.
The specification of `Symbol.hasInstance`.

Required Knowledge

Related Katas

Symbol

Difficulty Level

INTERMEDIATE

Stats

1 tests to solve