There is a code:
<script> function MyObject(name){ this.name = name; } var arr = new Array(); var my = new MyObject(); my.name = "1"; arr.push(my); my.name = "2"; arr.push(my); for (var i = 0; i < arr.length; i++){ console.log(arr[i]); } </script> falls into the log:
and it was expected that various objects with names 1 and 2 would be added to the array. What is the reason for such behavior and how to fix it?
