Different two ways of creating an object:-

Object Literals : This is the most common way to create the object with object literal.

For Example:

Ex:1
var emptyObj= {};
   Ex:2
     var emptyObj = {empId:"001", empCode: "X0091", empDetails : function (){
    alert("Hi");

};
};

Object Constructor: It is way to create object using object constructor and the constructor is used to initialize new object.

For Example:

Ex:1
Var obj = new Object();
Ex:2
var obj = new Object();
Obj.empId="001";
Obj.empCode="X0091";
Obj.empAddressDetails = function (){
console.log("Hi, I Anil");
};

results matching ""

    No results matching ""