<分区>
function Employee(name, dept) {
this.name = name || "";
this.dept = dept || "general";
}
function WorkerBee(projs) {
this.projects = projs || [];
}
WorkerBee.prototype = Object.create( Employee.prototype );
function Engineer(mach) {
this.dept = "engineering";
this.mach = mach || "";
}
Engineer.prototype = Object.create(WorkerBee.prototype);
var jane = new Engineer("belau");
console.log( 'projects' in jane );
正在尝试检查 jane
是否继承了 projects
属性。
输出 false
。为什么?