UNPKG

905 BJavaScriptView Raw
1'use strict';
2var isCallable = require('../internals/is-callable');
3var isObject = require('../internals/is-object');
4var definePropertyModule = require('../internals/object-define-property');
5var isPrototypeOf = require('../internals/object-is-prototype-of');
6var wellKnownSymbol = require('../internals/well-known-symbol');
7var makeBuiltIn = require('../internals/make-built-in');
8
9var HAS_INSTANCE = wellKnownSymbol('hasInstance');
10var FunctionPrototype = Function.prototype;
11
12// `Function.prototype[@@hasInstance]` method
13// https://tc39.es/ecma262/#sec-function.prototype-@@hasinstance
14if (!(HAS_INSTANCE in FunctionPrototype)) {
15 definePropertyModule.f(FunctionPrototype, HAS_INSTANCE, { value: makeBuiltIn(function (O) {
16 if (!isCallable(this) || !isObject(O)) return false;
17 var P = this.prototype;
18 return isObject(P) ? isPrototypeOf(P, O) : O instanceof this;
19 }, HAS_INSTANCE) });
20}