英 [?pr??t?ta?p]? ?美 [?pro?t?ta?p]??
n.原型,雛形,藍(lán)本
復(fù)數(shù): prototypes
javascript prototype屬性 語法
prototype屬性是什么?
prototype屬性是函數(shù)特有的屬性也是函數(shù)的原型對(duì)象。對(duì)原型對(duì)象增加的屬性及其方法,new實(shí)例化之后的對(duì)象都能繼承。
作用:prototype 屬性使您有能力向?qū)ο筇砑訉傩院头椒ā?/p>
語法:object.prototype.name=value
javascript prototype屬性 示例
<html> <body> <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> </body> </html>
運(yùn)行實(shí)例 ?
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例