ES6 Object Initializer

This lesson teaches how to use object initializer and how to initialize methods within them.

We'll cover the following...

In JavaScript ES6, you can use a shorthand property syntax to initialize your objects more concisely, like following object initialization:

Press + to interact
const name = 'Robin';
const user = {
name: name,
};
console.log('ES5', user);

When the property name in your object is the same as your variable name, you can do the following:

Press + to interact
const name = 'Robin';
const user = {
name,
};
console.log('ES6', user);

We can do the same thing in the application that we are building in this ...

Access this course and 1400+ top-rated courses and projects.