Creating Strings

chinmay.sahoo

New member
String is a very special built-in object because of the way you can create it. All strings belong to the built-in String object, so you can create strings as instances of the String object:

Code:
var str = new String("Hello!")

The general syntax is:

Code:
stringObjectName = new String(string)

stringObjectName is the name of the object you are creating, and string is any string, including literal strings in quotations as in the example. Strings created via this constructor function are considered objects. If you test their
data type using the typeof operator you will find that they are objects, not strings. However, all the string properties and methods work on such objects.
 
String is a very special built-in object because of the way you can create it. All strings belong to the built-in String object, so you can create strings as instances of the String object:

Code:
var str = new String("Hello!")

The general syntax is:

Code:
stringObjectName = new String(string)

stringObjectName is the name of the object you are creating, and the string is any string, including literal strings in quotations as in the example. Strings created via this constructor function are considered objects. If you test their
data type using the type of operator you will find that they are objects, not strings. However, all the string properties and methods work on such objects.

Thanks for this useful information
 
Back
Top