Frontend/25_01_07/mai/node_modules/es-abstract/2017/OrdinaryHasInstance.js

25 lines
567 B
JavaScript
Raw Permalink Normal View History

2025-01-28 10:38:27 +00:00
'use strict';
var $TypeError = require('es-errors/type');
var Get = require('./Get');
var IsCallable = require('./IsCallable');
var isObject = require('../helpers/isObject');
// https://262.ecma-international.org/6.0/#sec-ordinaryhasinstance
module.exports = function OrdinaryHasInstance(C, O) {
if (!IsCallable(C)) {
return false;
}
if (!isObject(O)) {
return false;
}
var P = Get(C, 'prototype');
if (!isObject(P)) {
throw new $TypeError('OrdinaryHasInstance called on an object with an invalid prototype property.');
}
return O instanceof C;
};