The String
object
When strings are compared for equality, both with the ==
and stricter ===
operator, their sequence of code points is compared - not their memory locations.
Loading TypeScript...
To keep a reference to a string's memory location, you can use new String("...")
to create an object that works in many ways like a string.
Loading TypeScript...
Notice that the data type of a String
object is different from the data type for normal strings (string
uncapitalized). Even though the resulting object can be used in most cases like a normal string, it has a different internal representation.
Loading TypeScript...