DEV Community

pampapati
pampapati

Posted on

How to create JavaScript Objects

-using {}

-using new Object()

-using Object.create()

-using Object.assign()

-using ES6 Class


Object Creation Using ES6 Class:

class Employee{
   constructor(name,dept){
       this.name = name;
       this.dept = dept;
   }
}

const firstEmployee = new Employee('Pavan','IT');
console.log(firstEmployee);

Output // 
{
name: 'Pavan', 
dept: 'IT'
}
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
pampapati profile image
pampapati

I am just creating contents for my reference, will try to add more detailed description