with + let

Michael Ficarra mficarra at shapesecurity.com
Sat Feb 6 18:58:01 UTC 2016


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

On Fri, Feb 5, 2016 at 10:21 AM, Francisco Tolmasky <tolmasky at gmail.com>
wrote:

> 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
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>


-- 
Shape Security is hiring outstanding individuals. Check us out at
*https://shapesecurity.com/jobs/
<https://shapesecurity.com/jobs/>*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160206/08d9775e/attachment.html>


More information about the es-discuss mailing list