关于prototype问题请教
请问调用prototype 是用函数名调用还是用对象名
下面这一段代码是可以走通的,employee 这个应该是一个对象,然后用对象调用的prototype
var employee= function (name,job,born)
{
this.name=name;
this.job=job;
this.born=born;
}
employee.prototype.salary=null;
bill.salary=20000;
document.write(bill.salary);
但是 把代码改成如下所示
function employee (name,job,born)
{
this.name=name;
this.job=job;
this.born=born;
}
var bill=new employee("Bill Gates","Engineer",1985);
bill.prototype.salary=null;
bill.salary=20000;
document.write(bill.salary);
还是用对象调用prototype ,但是不能走通 报错,求解释