instanceof在节点4中评估为真,但不在节点6中评估
当我在节点4中执行此操作时,最后一条语句的计算结果为true
,但是在节点6中,它的计算结果为false
。 为什么?
F = () => {}; F.prototype = {}; Object.create(F.prototype) instanceof F;
这很可能是Node 6.x中的一个错误。 考虑以下:
const Foo = () => {}; Foo.prototype = {}; const foo = Object.create(Foo.prototype); // false in Node 6, true in Chrome console.log(foo instanceof Foo); // true in Node 6, true in Chrome console.log(Foo[Symbol.hasInstance](foo));