An object is an entity, that has both properties and methods. In real life, everything is an object. Like mobile is an object. It has some properties like red in color.

In javascript, Object() constructor method is used to instantiate an object with a new operator. 'new' is a reserved keyword of javascript.

var obj = new Object();    

The generated object property name and value are defined as -

obj.name = 'mobile'
obj.color = 'red';
    

We can also define the object property name and value as -

obj['name'] = 'mobile';
obj['color'] = 'red';

We can also define an object using object literal as -

var obj = {
   "name" : "mobile",
   "color" : "red"
}





Read more articles


General Knowledge



Learn Popular Language