My code is like
var persons = [];
function Person(id, name) {
this.id = id;
this.name = name;
}
When I am trying to loop throught all persons, I'm getting an uncaught TypeError: Cannot read property "name" of undefined.
for (var person in persons) {
console.log(persons[person]);
}
I noticed that my console is logging all persons and adding an property values after them
[Person, $family: function, $constructor: function, each: function, clone: function, clean: function…]
I'm pretty sure that that the code is breaking after looping the first person.
I'm using jquery-1.11.1.js
Any ideas how to get rid of this error? Thank you in advance.