//class Person {} takes in 3 arguments (string ,number, string)
var pArray: Person[ ] = [ ];
var newP;
for (var i = 0; i < 10; i++) {
newP = new Person("", Math.floor(Math.random() * 1000), "");
pArray.push(newP);
}
Using the above piece of code, i got an array that is filled with 10 numbers, all of which are the same. The result is 10 of the last created number (10th number). This works with primitive types but not object types.
What is going on and how to correct it?