In the following code, I create a car object and modify an element by increasing the count. Each time I modify the car, I push it onto an array called yada. At the end, I access the 3rd car that gets put onto the yada array to see what the count is, but it reports a count of 6 instead of what I expected to be a count of 3.
<html>
<body>
<script>
var car = {limit:4, count:0, trigger:0};
var yada = new Array();
for(var i=0; i<6; i++)
{
car.count += 1;
if(car.count >= car.limit)
{
car.trigger = 1;
}
yada.push(car);
alert(car.count+" "+car.limit+" "+car.trigger);
};
alert(yada[2].count + " TEST ");
</script>
</body>
</html>