Working with String Class Properties using JavaScript

Working with string class properties:

A string is a sequence of characters. In JavaScript, all the strings are represented as an instance of string class. The purpose of string object is to perform all the operations on the stored text, such as finding the length of text. The string object is a wrapper class and a member of the global objects.

Properties of the string object:

S.No. Property Property
1.

constructor

Returns the function, which creates the prototype of the string object.

2.

Length

Returns the length of the string.

3.

Prototype

Adds properties and methods to an object.

Demo:

  1. Create the following document called StringProperties.html.

    notepad

  2. Write the following code:

    code

  3. Execute the script by Opening the file in the Web Browser. If you are using Internet Explore click on “Allow Blocked Content” to allow the script to execute and you are using Mozilla Firefox then click on allow “ActiveX Controls”.

    execute

Thanks for reading this blog.

Ebook Download
View all
Learn
View all