I am searching through existing data in Js through a variable, I found that maybe I can access the data through window["variable_name"]
, but Js can't find the variable.
How am I going to access the data, or is there a better way to store the data and access it.
The data format
let info1=[{"id":0, "label":"XXX"},{"id":1, "label":"XXX"}, ...];
let info2=[{"id":0, "label":"XXX"},{"id":1, "label":"XXX"}, ...];
.
.
.
let info2000=[{"id":0, "label":"XXX"},{"id":1, "label":"XXX"}, ...];
Trying to access the variable
for (let i=1; i<=2000; i++) {
console.log(window["info"+i]);
}