Javascript Reference - JavaScript String constructor








The String type is the object representation for strings and is created using the String constructor:

Browser Support

String constructor Yes Yes Yes Yes Yes

Example


var stringObject = new String("hello world"); 
console.log(stringObject);

The code above generates the following result.

char index

We can access an individual character with bracket notation and a numeric index:


var stringValue = "hello world"; 
console.log(stringValue[1]); //"e" 

The code above generates the following result.