pablocattaneo
6/25/2016 - 1:03 PM

Iterates over an object in JavaScript filtering his own properties avoiding iterate over prototype properties. Source: http://stackoverflow.

Iterates over an object in JavaScript filtering his own properties avoiding iterate over prototype properties. Source: http://stackoverflow.com/questions/684672/how-do-i-loop-through-or-enumerate-a-javascript-object/37892626#37892626

for (var key in object) {
  if (object.hasOwnProperty(key)) {
    alert(key + " -> " + object[key]);
  }
}