Declaration and Instantiation : Introduction : Object Oriented JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Object Oriented » Introduction »

 

Declaration and Instantiation











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;







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Object Oriented
» Introduction