JavaScript console prints assigned value of variable before it has been assigned?

后端 未结 8 800
Happy的楠姐
Happy的楠姐 2020-12-06 17:47

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

8条回答
  •  被撕碎了的回忆
    2020-12-06 18:05

    If you want to keep the console's functionality such as expanding objects in an array, I suggest using .slice, which makes a copy of the array which doesn't change when logging:

    console.log("COPIED 1", copied_array.slice());
    

提交回复
热议问题