In my code, I have a variable containing an array. I want to debug manipulations of that variable. I do not mind if the contents of the array are changing, but I have to see how often and when the array itself changes.
An example:
window.myarray = []
console.log(window.myarray); // outputs: []
window.myarray.push("bla"); // an irrelevant manipulation
console.log(window.myarray); // outputs: ["bla"]
window.myarray = ["bla"]; // a change of the array's identity!
console.log(window.myarray); // still outputs: ["bla"]
How can I detect, that the array that is stored in a variable has changed, even if the content of the old and new arrays are the same?