user1382306
user1382306

Reputation:

set array = one dimension's values of multidimensional object array

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 firstKeys' values only?

If so, what is it? Libs & plugins welcome.

Upvotes: 0

Views: 49

Answers (1)

Justin Niessner
Justin Niessner

Reputation: 245429

You can use the Array.map() function:

var newArr = objects.map(function(w){ return w.firstKey; });

Upvotes: 2

Related Questions