JavaScript Programmer’s Reference new (Operator/unary) (Web design software) An object construction
JavaScript Programmer’s Reference new (Operator/unary) An object construction operator. Availability: ECMAScript edition 2 JavaScript 1.0 JScript 1.0 Internet Explorer 3.02 Netscape 2.0 Netscape Enterprise Server 2.0 Opera 3.0 Property/method value type: An object whose type depends on the constructor -myObject = new aConstructorJavaScript syntax: -myObject = new anObject(someArguments) aConstructor An object constructor function anObject An object to clone Argument list: someArguments A collection of initial values for the new instance The new operator creates a new instance of the object it is operating on. As the object is created, the receiver’s Construct method is called with no arguments passed to it. Any initialization is only carried out by the Construct method. The associativity is from right to left. Refer to the operator precedence topic for details of execution order. Typically this would be used to instantiate core objects of the following types: . Array . Boolean . Date . Function . Number . Object . RegExp . String This can also be used to instantiate some host objects. See also: Array(), Associativity, Boolean(), Date(), Function(), Left-Hand-Side expression, List type, Number(), Object(), Operator Precedence, RegExp(), String() 1522