Reputation:
I have an Array()
of Object()
s with keys firstKey
and secondKey
.
Does a function exist that can set a var
equal to an Array()
of all of firstKey
s' values only?
If so, what is it? Libs & plugins welcome.
Upvotes: 0
Views: 49
Reputation: 245429
You can use the Array.map()
function:
var newArr = objects.map(function(w){ return w.firstKey; });
Upvotes: 2