Guest User

Untitled

a guest
Aug 25th, 2019
73
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const t1 = [
  2. { x: 1, y: 2 },
  3. { x: 3, y: 4 },
  4. { x: 5, y: 6 }
  5. ] //? [1, 2, 3, 4, 5, 6]
  6.  
  7.  
  8. t1.flatMap(c => [c.x, c.y])
  9.  
  10. const orders = [
  11. {
  12. orderId: 42,
  13. items: [
  14. {name: 'soap', price: 1.99},
  15. {name: 'shampoo', price: 4.99}
  16. ]
  17. },
  18. {
  19. orderId: 1337,
  20. items: [
  21. {name: 'toothpaste', price: 5.59},
  22. {name: 'toothbrush', price: 8.99}
  23. ]
  24. }
  25. ];
  26.  
  27. orders.flatMap(o => o.items.map(i => i.name));
RAW Paste Data