function employee(name,job,born){this.name=name;this.job=job;this.born=born;this.salary=12;}let c=123;var bill=new employee('xx','ss','pp');employee.prototype.salary=function(){ return this.born;}alert((bill.salary+'--000---'+employee.prototype.salary()));var alise=new employee('xx','ss','pp');alert((alise.salary+'--000---'+alise.salary()));
1 回答
DIEA
TA贡献1820条经验 获得超2个赞
第一个是12--000---undefined,employee.prototype.salary(),this.born没赋值,return undefined;
第二个alise.salary()出错,alise.salary是this.salary,为12,employee中有this.salary=12,把employee.prototype.salary覆盖,找的是this.salary(),报错
添加回答
举报
0/150
提交
取消