0
私は以下のコードを使用しています。Object.create()関数内で変数にアクセスできません
var emp = function employee(name, sal) {
this.empname = name;
this.sal = sal;
}
emp.prototype.getName = function() {
return this.empname
};
var man = new emp("manish", 100);
console.log(man.getName()); //prints manish
var man1 = Object.create(emp);
man1.empname = "manish1";
console.log(man1.prototype.getName()); //prints undefined.
いくつかのオブジェクトが代わりにmanish1未定義の印刷された作成、なぜ私が理解するのに役立ちます。
:http://stackoverflow.com/questions/3079887/javascript-inheritance-with-object-create – Rajesh