DEV Community

Discussion on: Explaining closures to myself

Collapse
 
brianjmiller profile image
Brian J. Miller

Careful with the definition of scoping here. The 'ifs' and 'for' loops do not create a new scope in JavaScript for just any "declared variable" as it has both "function scope" and (now) "block scope". Also, you aren't really "declaring variables", you are declaring constants. "Variables" declared with const or let have block scope, those declared with var have function scope.

Ref: developer.mozilla.org/en-US/docs/W...

Collapse
 
damcosset profile image
Damien Cosset

I see. Thank you for the clarification.