Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const t1 = [
- { x: 1, y: 2 },
- { x: 3, y: 4 },
- { x: 5, y: 6 }
- ] //? [1, 2, 3, 4, 5, 6]
- t1.flatMap(c => [c.x, c.y])
- const orders = [
- {
- orderId: 42,
- items: [
- {name: 'soap', price: 1.99},
- {name: 'shampoo', price: 4.99}
- ]
- },
- {
- orderId: 1337,
- items: [
- {name: 'toothpaste', price: 5.59},
- {name: 'toothbrush', price: 8.99}
- ]
- }
- ];
- orders.flatMap(o => o.items.map(i => i.name));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement