JS如何将变量作为一个对象的Key
https://www.cnblogs.com/wangweizhang/p/10643404.html 转自
var lastWord = 'last word'; var a = { 'first word': 'hello', [lastWord]: 'world' }; a['first word'] // "hello" a[lastWord] // "world" a['last word'] // "world"
https://www.cnblogs.com/wangweizhang/p/10643404.html 转自
var lastWord = 'last word'; var a = { 'first word': 'hello', [lastWord]: 'world' }; a['first word'] // "hello" a[lastWord] // "world" a['last word'] // "world"