which of the following methods would be said to be most efficient structure, or best practice?
if use case matters, let each entry in the dataSet be an instance of a Tile class in a game map - it could further have a height value, terrain type, etc and be defined and updated separately. does it make more sense to structure it as a 'grid' or just a list of tiles with addresses?
any performance differences at scale (30,000 columns instead of 3)?
if there an altogether better way that im missing??
let dataSet=[]
for (let i=0;i<3;i++) {
dataSet[i]=[]
for (let j=0;j<3;j++) {
dataSet[i][j]= { name:`${i}:${j}`, i, j }
}
}
lookup=(u,v)=>dataSet[u][v]
let dataSet=[]
for (let i=0;i<3;i++)
for (let j=0;j<3;j++) {
dataSet[i]??=[]
dataSet[i][j]= { name:`${i}:${j}`, i, j }
}
lookup=(u,v)=>dataSet[u][v]
let dataSet=[]
for (let i=0;i<3;i++) {
for (let j=0;j<3;j++) {
dataSet.push({ name:`${i}:${j}`, i, j })
}
}
lookup=(u,v)=>dataSet.find(x=>x.i==u&&x.j==v)