When the String() constructor is used in a new expression it creates a new object based on the String prototype.
The value property of the new object is the same as the string that would have been returned when the constructor was invoked as a function call.
The result of this function is a String object version of the value passed-in. If there is no passed in argument an empty string "" is returned.
Refer to the String() conversion function topic for a list of rules for converting other data types to strings.
Note that unlike the Object() constructor which can be called without its parentheses, calling the String() constructor without them yields an uninitialized object.
See also: | Constructor function, constructor property, Global object, new, Object() |
ECMA 262 edition 2 - section 15.1.3.4
ECMA 262 edition 2 - section 15.5.1
ECMA 262 edition 2 - section 15.5.3.1
ECMA 262 edition 3 - section 15.5.2
Prev | Home | Next |
String object | Up | String() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |