, , , , , , , , :
var fakePoint = {
x: Math.random(),
y: Math.random(),
fakeConstructor: Object.defineProperty(Point, Symbol.hasInstance, {
value(o) { return o.fakeConstructor == this; }
})
};
console.log(fakePoint instanceof Point)
, Point a custom hasInstance , , fakeConstructor . "x" in o && "y" in o - . , , ,
Object.defineProperty(Point, Symbol.hasInstance, {
value(o) { return o.fakeConstructor == this; }
});
var fakePoint = {
x: Math.random(),
y: Math.random(),
fakeConstructor: Point
};