Digamos que tengo 5 objetos, box0 box1 box2 box3 box4 box5 .
¿Hay alguna forma de acceder a sus miembros en un bucle for? Lo intenté de esta manera, pero no funcionó porque box${i} es una cadena
let boxCoordinates: Array<Coordinate> = []; for(let i=0;i<5;i++) { boxCoordinates.push(`box${i}`.current.getBoundingClientRect) //box0, box1, box2, box3, box4 }¿Hay alguna razón para no tenerlos todos rastreados en una matriz en primer lugar?
// Assuming their defined somewhere else const boxArray = [box1, box2, box3, box4, box5]; for (let i =0; i < boxArray.length; i++ ) { const box = boxArray[i]; // Do what you need with box now }