0

In this example, Google Chrome Devtools won't find variable "y" in closure scope, but it will show "x".

My guess is that "y" won't appear because it's not used.

Am I right?

enter image description here

  • 1
    I'd think the variable *is* created, but after `outer` runs, it can't be referenced anymore, so it gets GC'd, though maybe smart compilers would see that `y` is never used and not bother assigning it. Might be engine-dependent. – CertainPerformance Nov 07 '18 at 05:26

1 Answers1

0

It looks like it's engine dependent.

On Google Chrome (Version 70.0.3538.77 (Official Build) (64-bit)), I can't see "y" variable:

Chrome

However on Firefox variable "y" is accessible:

Firefox

I'm not sure how these engines work, I assume Chrome during compile time have a look at variable "y" and says "hey it's not used in this scope, we don't need it". Whereas Firefox includes it.