更新时间:2023-11-29 08:03:52
只有最近才有ES6。他们称为计算属性名称
Only recently with ES6. They are called "computed property names"
从 MDN :
从ECMAScript 2015开始,对象初始化器语法也是
支持计算的属性名称。这允许您在括号[]
中放入一个表达式
,这将被计算为属性名称。
Starting with ECMAScript 2015, the object initializer syntax also supports computed property names. That allows you to put an expression in brackets
[]
, that will be computed as the property name.