js prototype 添加属性对象

Posted OYP

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js prototype 添加属性对象相关的知识,希望对你有一定的参考价值。

在本例中,我们将展示如何使用 prototype 属性来向对象添加属性:

<script type="text/javascript">

function employee(name,job,born)
{
this.name=name;
this.job=job;
this.born=born;
}

var bill=new employee("Bill Gates","Engineer",1985);

employee.prototype.salary=null;
bill.salary=20000;

document.write(bill.salary);

</script>

以上是关于js prototype 添加属性对象的主要内容,如果未能解决你的问题,请参考以下文章