To prevent a javascript heap issue, I implement the usage of multiple arrays including 'family1', 'family2','family3' and 'dogs1', 'dogs2', 'dogs3'. For instance, you can use 'family1 and dogs1', or 'family132 and dogs132' to form a new array named 'results'.
How should I correctly pass the "id" value?
let id = 'value here'
this.family + id
this.dogs + id
Currently, my 'str' goes into the new array as: t-h-i-s-.-f-a-m-i-l-y-1
for (let i = 0; i < 20; i++) {
const id = 1;
let str = 'this.family'+id; // ?
let str = 'this.dogs'+id; // ?
console.log(str);
const result = {
familyType: str[i], // output: t-h-i-s-.-f-a-m-i-l-y-1
protocol: this.dogs1[i], // expecting original behavior
};
results.push(result);
}
}