javascript prototype attribute
Translation results:
English [ˈprəʊtətaɪp] US [ˈproʊtətaɪp]
##n.Prototype, prototype, blueprintPlural: prototypesjavascript prototype attributesyntax
What is the prototype attribute?
#The prototype attribute is a function-specific attribute and is also the prototype object of the function. The attributes and methods added to the prototype object can be inherited by objects after new is instantiated.
Function:The prototype attribute gives you the ability to add properties and methods to an object.
Syntax: object.prototype.name=value
javascript prototype attributeexample
<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>
Run instance »
Click the "Run instance" button to view the online instance