I have a demo here - https://stackblitz.com/edit/angular-w7vavy?file=src%2Fapp%2Fapp.component.ts
I have a simple function that creates an array of objects.
If I do a typeof on the array it says it's an object.
I'm I doing something wrong, is it an object or array, I need t to be an array
createData() {
this.testData = [];
console.log(typeof(this.testData));
for(let n:number=0; n<=this.dates.length-1;n++){
for(let i:number= 0; i<=4; i++){
this.testData[i] = {
data_1: Math.floor(Math.random() * (this.max - this.min)),
data_2: Math.floor(Math.random() * (this.max - this.min)),
data_3: Math.floor(Math.random() * (this.max - this.min)),
data_4: Math.floor(Math.random() * (this.max - this.min)),
date: this.dates[i]
}
}
}
console.log(this.testData)
console.log(typeof(this.testData));
}