JavaScript, transform object into array
- by Šime Vidas
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?