Convert associative array back to indexed array
JavaScript
var myObj = {"0": "1", "1": "2", "2": "3"};
var convertToList = function (object) {
var i = 0;
var list = [];
while (object.hasOwnProperty(i)) { // check if value exists for index i
list.push(object[i]); // add value into list
i++; // increment index
}
return list;
};
var result = convertToList(myObj); // result: ["1", "2", "3"]
console.log(result);