JS: Function.prototype[Symbol.hasInstance]
(new in JS: ECMAScript 2015)
f[Symbol.hasInstance](obj)-
Return
trueif the value off.prototypeis in the Prototype Chain of obj. Else,false.〔see Symbol Tutorial〕
The following are equivalent:
f[Symbol.hasInstance](obj)obj instanceof ff.prototype.isPrototypeOf(obj)
〔see instanceof Operator〕
// Example Symbol.hasInstance on a buildin function const xx = [3, 4]; console.log(Array[Symbol.hasInstance](xx)); console.log(xx instanceof Array); console.log(Array.prototype.isPrototypeOf(xx)); // Example Symbol.hasInstance on a user-defined function function F() {} let xx = new F(); console.log(F[Symbol.hasInstance](xx)); console.log(xx instanceof F); console.log(F.prototype.isPrototypeOf(xx));