我有一个数据对象,其键是数字,值是包含对象的数组。在代码的某个时刻,我想基于对象键从该对象中提取数组。
对象看起来像这样:
this.data = {
1: [{name: "John Doe", occupation: "farmer"}, {name: "Jane Doe", occupation: "teacher"}],
3: [{name: "Jack Doe", occupation: "plumber"}, {name: "Jean Doe", occupation: "hairdresser"}]
}
要提取数组,我要做类似的事情...
this.people = this.data[1];
现在,当我console.log this.data
时,它返回{1: Array(2), 3: Array(2)}
当我console.log this.people
时,它给了我(2) [{…}, {…}]
但是,typeof(this.people)
返回object
。我不明白
这是什么问题?