let fruit = {
apple: [1, 2],
orange: [3, 4],
banana: [5, 6],
};
let allFruits = fruit.apple.concat(fruit.orange).concat(fruit.banana);
I can do something like this but what if I have like 20 fruit... Any other way maybe with lodash?
For the sake of completeness, here's how one can do it with lodash:
_.flatMap(fruit)
Yep, that simple. Two hidden tricks here: