This might be a quite easy question, but I haven't encountered an elegant solution.
How do you get all objects from an array by a single field. For example;
var users = [{name:'John', age: 20},
{name:'Sarah', age: 21},
{name:'George', age:34}];
var names = magicFunction(users, 'name');
// names = ['John', 'Sarah', 'George'];
// Another challenge is not to get field name (in this case 'name') with the value
I wonder if you could do it with functions like filter or map, without writing a long function?