ES6 - String length property


Advertisements

The prototype property allows you to add properties and methods to any object (Number, Boolean, String, Date, etc.).

Note − Prototype is a global property which is available with almost all the objects.

Syntax

string.prototype

Example:Object prototype

function employee(id, name) {
   this.id = id;
   this.name = name;
}
var emp = new employee(123, "Smith");
employee.prototype.email = "smith@abc.com";
console.log("Employee 's Id: " + emp.id);
console.log("Employee's name: " + emp.name);
console.log("Employee's Email ID: " + emp.email);

Output

Employee’s Id: 123
Employee’s name: Smith
Employee’s Email ID: smith@abc.com
Advertisements