Guest User

Untitled

a guest
Mar 17th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. // ES5
  2. var arrayObjects = [
  3. {
  4. id: 1,
  5. name: "A"
  6. },
  7. {
  8. id: 2,
  9. name: "B"
  10. },
  11. {
  12. id: 3,
  13. name: "C"
  14. }
  15. ];
  16.  
  17. Array.prototype.map.call(arrayObjects, function(item) { return item.id; }).join(","); // "1,2,3"
  18.  
  19.  
  20. // ES6 / TypeScript
  21. const arrayObjects = [
  22. {
  23. id: 1,
  24. name: "A"
  25. },
  26. {
  27. id: 2,
  28. name: "B"
  29. },
  30. {
  31. id: 3,
  32. name: "C"
  33. }
  34. ];
  35. Array.prototype.map.call(arrayObjects, s => s.id).toString(); // "1,2,3"
Add Comment
Please, Sign In to add comment