JavaScript: String Object
String
is the value of the property key "String"
of the Global Object
.
console.log( window.String === String );
Type
Type of String
is a function.
// type of String console.log( typeof String === "function" );
Parent
Parent of String
is Function.prototype.
// parent of String console.log( Reflect.getPrototypeOf ( String ) === Function.prototype );
Purpose
Purpose of String
is:
String(value)
is used to convert any (primitive or object) value to a string primitive.new String(value)
is used to convert any (primitive or object) value to a string object.- Used as a namespace to hold general purpose methods for working with string or character.
- Holds the property key
"prototype"
. The value ofString.prototype
is the parent object of all string instances and string primitives.
[see Primitive Value]