New Object Functionality

Objects have been upgraded with ES2015. We'll go over short-hand property assignment and short-hand method naming. We'll go over getters and setters and see how they allow us to implement cleaner interfaces for working with data.

We'll cover the following...

Properties

If we’re adding a variable as a property to an object, we’d do it like this.

Press + to interact
var name = 'Sophia';
var age = 25;
var person = {
name: name,
age: age
};

We can now omit the colon and the variable name repeat, as long as the variable name is the same as the property name we want on the object. In other words, the block above is the same as this one. ...

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