想象一下这个对象:
var obj = {
one: {
two:{
three: "whatever"
}
}
}
如果我想访问“任何”,我只需这样做:
console.log( obj.one.two.three ) --> "whatever"
我什至可以使用如下变量:
var one = "one"
console.log( obj[one].two.three ) --> "whatever"
但是为什么这不起作用?
var onetwo = "one.two"
console.log( obj[onetwo].three ) --> undefined