你这几个判断,我机器上的输出都是true啊,环境时node -v =>v6.1.0
测试代码:
"use strict";
function Base(name)
{
this.name=name
}
function Derived(name,age)
{
//Base.call(this,name);
this.age=age
}
Derived.prototype=new Base("aaa")
var d1=new Derived("name1",22);
var d2=new Derived("name2",23);
console.log("name" in d1)
console.log("name" in d2)
console.log("name" in Derived.prototype)
console.log("name" in Object.getPrototypeOf(d1))
console.log("name" in Object.getPrototypeOf(d2))
【 在 XeCycle (据说是小 X) 的大作中提到: 】
: "name" in d1 -> true
: "name" in d2 -> true
: "name" in Derived.prototype -> false
: ...................
--
FROM 159.226.171.*