如果有:
var obj = {a: 'This is a', b: 'This is b', c: 'This is c'}
var select = 'b';
我怎样才能做到这样的工作:
console.log(obj.select); // This would output: This is b
答案 0 :(得分:2)
var obj = {
a: 'This is a',
b: 'This is b',
c: 'This is c'
}
var select = 'b';
console.log(obj[select]);