2016-10-10 03:43:44 +02:00
|
|
|
'use strict';
|
2017-04-20 03:09:25 +02:00
|
|
|
var $ = require('./$')
|
|
|
|
, isObject = require('./$.is-object')
|
|
|
|
, HAS_INSTANCE = require('./$.wks')('hasInstance')
|
|
|
|
, FunctionProto = Function.prototype;
|
2016-10-10 03:43:44 +02:00
|
|
|
// 19.2.3.6 Function.prototype[@@hasInstance](V)
|
2017-04-20 03:09:25 +02:00
|
|
|
if(!(HAS_INSTANCE in FunctionProto))$.setDesc(FunctionProto, HAS_INSTANCE, {value: function(O){
|
2016-10-10 03:43:44 +02:00
|
|
|
if(typeof this != 'function' || !isObject(O))return false;
|
|
|
|
if(!isObject(this.prototype))return O instanceof this;
|
|
|
|
// for environment w/o native `@@hasInstance` logic enough `instanceof`, but add this:
|
2017-04-20 03:09:25 +02:00
|
|
|
while(O = $.getProto(O))if(this.prototype === O)return true;
|
2016-10-10 03:43:44 +02:00
|
|
|
return false;
|
|
|
|
}});
|