Here is a shorter way of achieving it:
let result = objArray.map(a => a.foo);
OR
let result = objArray.map(({ foo }) => foo)
You can also check Array.prototype.map()
.
Here is a shorter way of achieving it:
let result = objArray.map(a => a.foo);
OR
let result = objArray.map(({ foo }) => foo)
You can also check Array.prototype.map()
.
Compare two dates with JavaScript
How do I loop through or enumerate a JavaScript object?
Is there a JavaScript equivalent of PHP’s “variable variables”?
What is the (function() { } )() construct in JavaScript?
How do I copy to the clipboard in JavaScript?
Where can I find documentation on formatting a date in JavaScript?
How do I redirect to another webpage?
Sort array of objects by string property value