instanceof 在节点 4 中计算为真,但在节点 6 中不计算

instanceof evaluates to true in Node 4 but not Node 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));

前两个日志应该return相同的值,因为instanceof运算符被定义为调用returnFoo@@hasInstance方法,如果存在( §12.9.4). What is more interesting, node throws TypeError in the following case, while false is expected, as Foo is not callable (§7.3.19):

const Foo = {
  "prototype": {},
  [Symbol.hasInstance]: Function.prototype[Symbol.hasInstance]
};
const foo = Object.create(Foo.prototype);
// throws in Node 6, false in Chrome
console.log(foo instanceof Foo);
// false in Node 6, false in Chrome
console.log(Foo[Symbol.hasInstance](foo));

PS

Node v6.2.2(64 位)用于 Windows 系统上的测试。