저는 Pers에서 온 파생 된 (Perspective) 직원과 직원이 있습니다.프로토 타입을 사용할 때 JavaScript 객체를 덮어 씁니다.
Pers = function(options){
this.Name;
this.ID;
this.init = function(options){
this.Name=options.Name;
this.ID=options.ID;
}
}
Employee = function(options){
this.Sal;
this.init = function(options){
this.Sal=options.Sal;
this.__proto__.init(options);
}
this.init(options);
}
Employee.prototype=new Pers();
지금 나는 두 번 "타냐"을 얻을 것이다 ...
var o=new Employee({Name:"Nik",ID:"1",Sal:100});
var p=new Employee({Name:"Tanja",ID:"2",Sal:200});
새로운 개체를 만들고 자신의 이름을 알릴 때.
누구에게 아이디어가 있습니까?
더 이상 '__proto__'을 사용하면 안됩니다. –