Microsoft® JScript™
new Operator
 Language Reference 
Version 1 

See Also


Description
Creates a new object.
Syntax
new constructor[(arguments)]

The constructor argument calls object's constructor. The parentheses can be omitted if the constructor takes no arguments.

Remarks
The new operator performs the following tasks:
  1. It creates an object with no members.
  2. Sets the "constructor" attribute of the new object to the constructor function.
  3. It calls the constructor for that object, passing a pointer to the newly created object as the this pointer.
  4. Returns this if the constructor doesn't return it's own object.

The constructor then initializes the object according to the arguments passed to the constructor. These are examples of valid uses of the new operator:

my_object = new Object;
my_array = new Array();
my_date = new Date("Jan 5 1996");


© 1997 by Microsoft Corporation. All rights reserved.

Comments: