首页 > 代码库 > 对象结构小结

对象结构小结

var index = [‘first‘, ‘second‘];
var data = http://www.mamicode.com/{
‘first‘: [1,2,3],
‘second‘: [4,5]
}
console.log(index[0]); //first
console.log(data[index[0]]); //1,2,3
console.log(data.index[0]); //报错
console.log(data[‘first‘]); //1,2,3
console.log(data.first); // 1,2,3