My code looks similarly to this:
I create variable:
var person1;
Than I add this to array:
var people = [];
people.push(person1);
And finally I define what "person1" is:
person1 = new Person("Mike", 25, "London");
The problem is, people that are defined after pushing to array are undefined. For some reasons I can't define all people before putting to array. As I see, "people.push(person1);" actually puts copy of this variable to array. It is possible to do, that I put only reference of variable to the array?
var people = {}; people.push(person1);does not work, it's not an array ([]).