When I loop through an object in Javascript to extract its keys, why do the keys convert to string when they were intended to be integers ?
obj = {1:'a', 2:'b'};
arr = [];
for(var key in obj){
if (obj.hasOwnProperty(key)){
arr.push(key);
}
}
Now arr
is [ "1", "2" ]
instead of [1, 2]