I have this function
then I run this:
The first alert says:
but the second says:
How can I pass by value, or copy an array by value? I can't understand memory management in javascript.
Code:
function test(n)
{
alert(n[0]);
var a = n;
a.shift();
alert(n[0]);
}
Code:
test(Array(1,2));
Code:
1,2
Code:
2
Comment