Chrome JS Console only pre-evaluates (displays a gray result before you hit enter on a line of JavaScript code) expressions that don't have side effects. How does Chrome tell? Side effects tested: changing closured(non-local) variables, altering objects pointed to by non-local variables (including accessing properties with get()
attributes that have side effects), async code (setTimeout
), console.log
, etc.
V8 has massive lists denoting which internal operations ("bytecode handlers", "intrinsics", and "builtins") are considered side effect free for this feature's purposes. See src/debug/debug-evaluate.cc for all the gory details.
(This distinction is in no way exposed to, or relevant for, regular JavaScript operation; it's purely for debugger features.)