Let's say hypothetically that we
- instantiated an array object
- referenced that array object in another array
- print out the array reference
- change the initial array's values
let initialArray = [1,2,3,4,5]
let referenceArray = [initialArray,6]
console.log(referenceArray)
initialArray.pop()
the output at chrome browser 96 Array(2) 0: (4) [1, 2, 3, 4] 1: 6 length: 2 However at nodeJs the output is [ [ 1, 2, 3, 4, 5 ], 6 ]
Why initialArray's value got popped at the browser but not nodeJs ?
Edit:
The referenced question states that it's fixed bug ,however the 10 years old question's error still persist , so it's clearly not related to such long-gone resolved bug .
Also the behavior i listed at this question only takes place when referencing another array object
let initialArray = [1,2,3,4,5]
console.log(initialArray)
initialArray.pop()
normally outputs [1, 2, 3, 4, 5]