📌  相关文章
📜  javascript 通过变量设置对象键 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:45.747000             🧑  作者: Mango

代码示例3
//For ES6 and Babel
{
    [yourKeyVariable]: "yourValue",
}

// ES5 Alternative
// Create the object first, then use [] to set your variable as a key
var yourObject = {};

yourObject[yourKeyVariable] = "yourValue";