with + let
# Bradley Meck (10 years ago)
var is hoisted and unified for multiple definitions (each definition
refers to 1 hoisted variable slot). let cannot have multiple definitions
that are in the same lexical scope. Using var inside the loop would have
no effect since it is unified to the declaration outside of the loop.
# Michael Ficarra (10 years ago)
Francisco, remember that the with-statement can have any statement as its
body. For example, with (a) x = 20; would modify a.x. But the let x
in the block is shadowing the x that is in scope in the with-statement
body.
Michael Ficarra
Just curious how the following code should behave:
var a = { x: 10 }; with (a) { let x = 20; } console.log(a.x);a.x is still 10 in a repl I tried. However, if it was var x in the with x would be 20. Is let not affecting the with expected behavior?
Just curious how the following code should behave: ```javascript var a = { x: 10 }; with (a) { let x = 20; } console.log(a.x); ``` a.x is still 10 in a repl I tried. However, if it was var x in the with x would be 20. Is let not affecting the with expected behavior? -- Francisco Tolmasky www.tolmasky.com tolmasky at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160205/64b740f2/attachment.html>