June 2016
Intermediate to advanced
910 pages
18h 59m
English
ES6 has added some new syntax-based extensions to the {} object literal for creating properties. Let's see them:
ES6 provides a shorter syntax for assigning the object properties to the values of the variables, which have the same name as the properties.
In ES5, you have been doing this:
var x = 1, y = 2;
var object = {
x: x,
y: y
};
console.log(object.x); //output "1"In ES6, you can do it this way:
let x = 1, y = 2;
let object = { x, y };
console.log(object.x); //output "1"ES6 provides a new syntax for defining the methods on an object. Here is an example to demonstrate the new syntax:
let object = { myFunction(){ console.log("Hello World!!!"); //Output "Hello World!!!" } } object.myFunction(); ...Read now
Unlock full access