var index = [‘first‘, ‘second‘];
var data = {
‘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
对象结构小结
时间: 2024-10-31 07:43:00