Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ES5
- var arrayObjects = [
- {
- id: 1,
- name: "A"
- },
- {
- id: 2,
- name: "B"
- },
- {
- id: 3,
- name: "C"
- }
- ];
- Array.prototype.map.call(arrayObjects, function(item) { return item.id; }).join(","); // "1,2,3"
- // ES6 / TypeScript
- const arrayObjects = [
- {
- id: 1,
- name: "A"
- },
- {
- id: 2,
- name: "B"
- },
- {
- id: 3,
- name: "C"
- }
- ];
- Array.prototype.map.call(arrayObjects, s => s.id).toString(); // "1,2,3"
Add Comment
Please, Sign In to add comment