Object Enhancement

var color = "red";
var speed = 10;
var drive= 'driveBMW';
fuction go(){}

var car = {color, speed, go, [drive]: function(){}}; // ES5 - {color: color, speed: speed}

console.log(car.color);
console.log(car.speed);
car.go();
car.driveBMW();

Shorthand properties

var firstname = "Hemant";
var lastname = "Singh";

var fullname = {firstname, lastname};

var prefix = 'Mr.';

var person = {prefix, fullname};
console.log(person);

Last updated