I want to duplicate one array of objects into multiple ones, because every one of them I need to use in separate places.
if(!this.tempLookups){
for (let count = 0; count < this.dates.length; count++) {
this.tempLookups[count] = this.lookups[key];
}
}
Error: Uncaught (in promise) TypeError: Cannot set property '0' of null
this.tempLookups = []after the if conditionthis.tempLookups = new Array(this.dates.length).fill(this.lookups[key])this.lookups[key]an array?this.lookupsis array of arrays, than you should useArray.fromto create shallow copy ofthis.lookups[key]array - see my answer.