更新时间:2023-08-25 23:04:22
4castle pointet out,你可以使用计算对象属性名称和解构以及用于解构的附加键/值对变量。
As 4castle pointet out, you could use Computed object property names and destructuring with an additional key/value pair variables for destructuring.
var object = { item: { a: 'a0', b: 'b0' } },
key = 'b',
value;
({ [key]: value } = object.item);
console.log(value);