Javascript - Iterating through list of keys for associative array

http://stackoverflow.com/questions/558981/iterating-through-list-of-keys-for-associative-array-in-json

by katalin_2003

JavaScript

var dictionary = {
    "cats": [1, 2, 3, 4, 5],
        "dogs": [6, 7, 8, 9, 10]
};

//var keys = [];
for (var key in dictionary) {
    if (dictionary.hasOwnProperty(key)) {
        console.log("do something with " + key);
        //        keys.push(key);
    }
}
//console.log(keys);