In google chrome, if you want to register objects with the state that they had during logging, you need to register a clone object or just reinforce it.
var a = []; console.log(a); a[0] = 3;
It will keep a log [3] because it registers a living object, whereas it will log [] :
var a = []; console.log(JSON.parse(JSON.stringify(a))); a[0] = 3;
It is also a record in a real object, but it is a cloned clone that was cloned at a point in time when a had no elements.
This is not related to possible logical errors in the code pointed out by @CallumRogers.
source share