Home >>JavaScript String Methods >JavaScript String Prototype Property

JavaScript String Prototype Property

JavaScript String Prototype Property

JavaScript prototype property is used to add new properties and methods to the existing object types. It is a global property which is available with almost all JavaScript objects.

Syntax:

object.prototype.name = value

Browser Support

Property Chrome Edge Firefox Safari Opera
prototype Yes Yes Yes Yes Yes

Here is an example of prototype property:

<html>
<body>
<p id="demo"></p>
<script>
function employee(name, jobtitle, born) {
  this.name = name;
  this.jobtitle = jobtitle;
  this.born = born;
}
employee.prototype.salary = 5000;
var jerry = new employee("Jerry", "Developer", 1999);
document.getElementById("demo").innerHTML = jerry.salary;
</script>
</body>
</html>
Output:

 

 


No Sidebar ads