Within my code, I am working with a data object that has numerical keys and arrays as values containing objects. There comes a point where I need to retrieve a specific array from the object based on its key.
The structure of the object is similar to this:
this.data = {
1: [{name: "John Doe", occupation: "farmer"}, {name: "Jane Doe", occupation: "teacher"}],
3: [{name: "Jack Doe", occupation: "plumber"}, {name: "Jean Doe", occupation: "hairdresser"}]
}
In order to extract the arrays, I utilize the following snippet...
this.people = this.data[1];
Upon logging this.data
, it displays {1: Array(2), 3: Array(2)}
. When I log this.people
, it shows (2) [{…}, {…}]
.
However, the output of typeof(this.people)
confuses me as it returns object
. What could be causing this issue?