オブジェクトのキーを[変数]
とすると変数で指定できます。
const key = 'sampleKey'
const obj = {[key]: 'sampleValue'}
console.log(obj) // {sampleKey: 'sampleValue'}
Go to list of users who liked
Share on X(Twitter)
Share on Facebook
More than 1 year has passed since last update.
オブジェクトのキーを[変数]
とすると変数で指定できます。
const key = 'sampleKey'
const obj = {[key]: 'sampleValue'}
console.log(obj) // {sampleKey: 'sampleValue'}
Register as a new user and use Qiita more conveniently
Go to list of users who liked