📜  动态属性,而不是 javascript 代码示例

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

代码示例1
var foo = { pName1 : 1, pName2 : [1, {foo : bar }, 3] , ...}

var name = "pName"
var num  = 1;

foo[name + num]; // 1

// -- 

var a = 2;
var b = 1;
var c = "foo";

foo[name + a][b][c]; // bar