Javascript examples for String:prototype
The prototype property can add new properties and methods to existing object types.
A reference to the String.prototype object
The following code shows how to Use the prototype property to add a new property to all objects of a given type:
<!DOCTYPE html> <html> <body> <p id="demo"></p> <script> function employee(name, jobtitle, born) { this.name=name;/* ww w .j ava 2 s . c o m*/ this.jobtitle=jobtitle; this.born=born; } employee.prototype.salary = 2000; var fred = new employee("Mary", "Programmer", 1990); document.getElementById("demo").innerHTML = fred.salary; </script> </body> </html>