array of objects
let data = data.prezzi[cond];
// empty array
let prezzi = [];
data.forEach((el, idx) => {
// check if there's something in that index ?, if not, set it to an empty array
if (!prezzi[idx]) prezzi[idx] = [];
// prezzi[idx] is an empty array
// cond = "ac"
// You are setting a non-numeric property to this empty array
prezzi[idx][cond] = el;
})
You can access it like
prezzi[0][cond]
Let's say cond = "ac"
prezzi[0].ac
Or
prezzi[0]["ac"]
thank you, i'll try, but I think there's something with the async, because at the end the returned prezzi obj is ok
i guess was also what you were saying here
Обсуждают сегодня