JS prototype 增加属性

  直接上代码

<script type="text/javascript">
function employee(name,jobtitle,born)
{
this.name=name;
this.jobtitle=jobtitle ;
this.born=born;
}
var fred=new employee("Fred Flintstone","Caveman",1970);
employee.prototype.salary=null;
fred.salary=20000;
document.write(fred.salary);
</script>

  

你可能感兴趣的:(JavaScript,prototype)