I think V8 optimizes away x
in the forEach
callback since it is not used there. See the Closures listed in the debugger.
And if you don't access y
, it goes away, too.
I would be surprised if this mattered either way, since the function's stack frame is short-lived.