ES6对象速记符号可以与常规对象符号结合使用吗? [英] Can ES6 object shorthand notation be combined with regular object notation?
本文介绍了ES6对象速记符号可以与常规对象符号结合使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
借助ES6,我们现在可以利用对象简写符号来创建对象...
With ES6 we can now utilize object shorthand notation for creating objects...
var a = 1, b = 2, c = 3;
var obj = { a, b, c };
是否可以将速记符号与常规符号相结合?
Is it possible to combine shorthand notation with regular notation?
换句话说,以下是合法的吗?
In other words, is the following legit?
var obj = {a, b, c, d: 'foo'};
如果是的话,我应该注意一些陷阱吗?
And if so, are there any gotchas I should be aware of?
推荐答案
是否可以将速记符号与常规符号相结合?
Is it possible to combine shorthand notation with regular notation?
是的.属性定义可以是以下任意一种:
Yes. A property definition can be any of the following:
PropertyDefinition :
IdentifierReference
CoverInitializedName
PropertyName : AssignmentExpression
MethodDefinition
如果是的话,我应该注意一些陷阱吗?
And if so, are there any gotchas I should be aware of?
不.
这篇关于ES6对象速记符号可以与常规对象符号结合使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文