Consider the following test:
a={a:'a'}
. It returns an object.
a.a='b'
- expand the return from the first command. It shows
a: "b"
So, an object is always shown in the state it is in when it first gets open in the Chrome developer console. For (pseudo-)arrays, what matters is the state of the object when the console gets to it. This could be right after the normal javascript returns (hard to tell why. Performance reasons, perhaps).
You can handle this by always logging elements that don't change, such as:
- primitive values:
console.log("hello")
- clones of DOM nodes or jQuery objects:
console.log($(this).find(".buttons .cancel").clone())
If logging an immutable object is not an option, you can still log while tracing the code: console.log(document); debugger;