📜  动态访问对象属性 javascript 代码示例

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

代码示例2
let nestedObject = { levelOne: { levelTwo: { levelThree : 'final destination'} } }

const prop1 = 'levelOne';
const prop2 = 'levelTwo';
const prop3 = 'levelThree';

var destination = nestedObject[prop1][prop2][prop3];

// destination = 'final destination'