Consider the following code:
obakaSan = new Object();
obakaSan.age = 14;
hairetsu = [];
hairetsu.push(obakaSan);
ahoSan = obakaSan;
alert( obakaSan.age ", " "ahoSan.age ", " hairetsu[0].age );
This one should give the same number for each object ( giving a message box "14, 14, 14"). Now, try this:
delete hairetsu[0];
Thus doing alert(hairetsu[0].age) will cause an error, but alert(obakaSan.age) still produces output. But,
delete ahoSan;
will also effectively delete obakaSan as well, causing error when doing alert(obakaSan.age). Does this imply that deleting object from array only removes the reference to the object and not the object itself?
Tags: