Javascript Question. I am pretty new to javascript so pardon me if anything is not clear.
Please play following example at (right click) "inspect --> Console".
Example:
o = [1,2,3];
y = o;
delete y[0];
y;// result: [undefined × 1, 2, 3]
o;// result: [undefined × 1, 2, 3]
Is it possible that the delete of y
does not affect o
? Here I made y
equal to o
. I just wanted to delete the first item of y
but not o
. However, o
changes with y
together. I wonder if it is possible to prevent o
being changed even I change y
?