I\'m deeply confused by the behaviour of either JavaScript, or the Chrome console. Can someone help me understand?
Basically I have the following JavaScript code, no
Since arrays are passed by reference, every change you make to it will change what is output in the console. It is partly the behavior of Chrome's console, partly JavaScript's.
If you want to print the result at the time of the call to console.log, you could output it as a string using JSON.stringify.
console.log("COPIED 1", JSON.stringify(copied_array));
Important edit
It seems I was mostly wrong. As diEcho pointed out in the question's comments, a similar question has a better answer. It seems to be solely Chrome behavior.