Given an object as following:

var o = {
    "k1": "value1",
    "k2": "value2",
    "k3": "value3"
};

To loop through it, then do following:

for (var key in o) {
    if (o.hasOwnProperty(key)) {
        console.log(key + " - " + JSON.stringify(o[key]));
    }
}
Output
k1 - "value1"
k2 - "value2"
k3 - "value3"

References:
MDN Web Docs -Object.prototype.hasOwnProperty()

Last modified: January 13, 2018

Author