JavaScript String Object Property

Hello folks, today we will discuss about JavaScript String Object Property with examples.

•  JavaScript constructor Property

The JavaScript constructor property returns function that created the String object’s prototype

Example:

var str = ‘Hello’;

alert(str.constructor);

Live Demo: JavaScript String Object Properties-contructor

JavaScript length Property

The JavaScript length property returns the length of a string in characters.

Syntax:
string.length

Example:

var str = “This is JavaScript length property”;
alert(str.length); // OUTPUT: 84

Live Demo:JavaScript string length property

JavaScript prototype Property

Use the JavaScript prototype property to add a property to an object which is been bellow example

function friends(firstName,born)
{
this.name=name;
this.born=born;
}

var pole=new friends(“Pole”, 1970);
friends.prototype.lastName=null;
pole.lastName=”Sabe”;
alert(pole.lastName);

Live Demo: JavaScript proptotype property

Leave a Reply