JSFiddle - React, Tailwind, and code Playground
by Hugh Chapman
HTML
<div></div>
JavaScript
var stooges = [{name: 'moe', age: 40}, {name: 'larry', age: 50}, {name: 'curly', age: 60}];
var pluck = function(list,keyToPluck){
var plucked = [];
for(var i = 0,len = list.length; i < len; i++){
// iterate over list
var keys = list[i];
for (var key in keys) {
// can't use hasOwnProperty here because object created by notation
// store value in an array to return
if (key == keyToPluck ) plucked.push(list[i][key]);
}
}
return plucked;
};
$('div').text(pluck(stooges,'name')).toString();