码迷,mamicode.com
首页 > 其他好文 > 详细

[ES6] 12. Shorthand Properties in ES6

时间:2014-11-23 01:53:42      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   io   color   os   sp   on   div   

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

标签:des   style   blog   io   color   os   sp   on   div   

原文地址:http://www.cnblogs.com/Answer1215/p/4116075.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!