Where destructuring in ES6 allows you to easily get properties out of an object, this shorthand property syntax allows you to easily push properties in.
let firstName = "Answer"; let lastName = "Question"; let person = {firstName, lastName} console.log(person); // { firstName: ‘Answer‘, lastName: ‘Question‘ } let mascot = "Moose"; let team = {person, mascot}; console.log(team); // { person: { firstName: ‘Answer‘, lastName: ‘Question‘ }, //mascot: ‘Moose‘ }
[ES6] 12. Shorthand Properties in ES6
原文:http://www.cnblogs.com/Answer1215/p/4116075.html