JavaScript, transform object into array
Posted
by
Šime Vidas
on Stack Overflow
See other posts from Stack Overflow
or by Šime Vidas
Published on 2011-01-05T18:48:25Z
Indexed on
2011/01/05
18:53 UTC
Read the original article
Hit count: 205
JavaScript
|jQuery
I've got an object:
var obj = {
"Mike": 24,
"Peter": 23,
"Simon": 33,
"Tom": 12,
"Frank": 31
};
I want to create an array that holds the values of the object. The keys (key names) can be disregarded:
[24, 23, 33, 12, 31]
The order of the values is NOT important!
One solution (obviously) would be do have a function that takes the values and puts them into an array:
var arr = valuesToArray(obj);
I will accept such a function as the answer. However, I would be more pleased if there would be an API function (ECMAScript, jQuery, browser-specific, ...) that could do this. Is there such a thing?
© Stack Overflow or respective owner