Online

JavaScript - Strings

The String object lets you work with a series of characters; it wraps Javascript's string primitive data type with a number of helper methods. As JavaScript automatically converts between string primitives and String objects, you can call any of the helper methods of the String object on a string primitive.

Syntax :-

Example :-

Result

Strings are written inside quotes. You can use single or double quotes:
Volvo XC60 Volvo XC60

constructor

A constructor returns a reference to the string function that created the instance's prototype.

Example :-

Result

str.constructor is: function String() { [native code] }

length

This property returns the number of characters in a string.

Example :-

Result

str.length is:14

prototype

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

Example

Result

Book title is : Perl
Book author is : Mohtashim
Book price is : 100