Objects are created by using the new keyword followed by the name of the class.
var oObject = new Object(); var oStringObject = new String();
The first line creates a new instance of Object and stores it in the variable oObject;
The second line creates a new instance of String and stores it in the variable oStringObject.
The parentheses aren't required when the constructor doesn't require arguments, so these two lines could be rewritten as follows:
var oObject = new Object; var oStringObject = new String;
25.1.Introduction | ||||
25.1.1. | Declaration and Instantiation | |||
25.1.2. | Dereferencing Objects | |||
25.1.3. | Native Objects |