String prototype Property - Javascript String

Javascript examples for String:prototype


The prototype property can add new properties and methods to existing object types.

Return Value:

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:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<p id="demo"></p>

function employee(name, jobtitle, born) {;/* ww  w .j  ava 2  s  .  c  o  m*/
employee.prototype.salary = 2000;

var fred = new employee("Mary", "Programmer", 1990);
document.getElementById("demo").innerHTML = fred.salary;


Related Tutorials