string

string — A primitive string.

Description

string

Examples

Example #1 – string
var a = 'foo'; var b = new String('bar'); console.log(typeof a); // string console.log(typeof b); // object console.log(a); // foo console.log(b); // String {"bar"} console.log(a.toUpperCase()); // FOO console.log(b.toUpperCase()); // BAR
Example #2 – string
var a = 'foo'; var b = new String('foo'); a.x = 'bar'; b.x = 'bar'; console.log(a); // foo console.log(b); // String {"foo", x: "bar"} console.log(a.x); // undefined console.log(b.x); // bar

See also

External references