Creating top-level scopes in ES6 and do blocks

Axel Rauschmayer axel at rauschma.de
Mon Nov 4 03:36:46 PST 2013


What is the best way to create top-level scopes in ES6?

This isn’t possible, any more, right (given that nested module won’t be in ES6)?

```js
module {
    let foo = ...;
}
```

Then we are left with:

```js
{
    'use strict';
    let foo = ...;
}
```

On the other hand, it would be nice to have `do { ... }` blocks (of which I don’t know the current status), which would eliminate the remaining use case for IIFEs. With do blocks, the above would become shorter:

```js
do {
    let foo = ...;
}
```

It may make sense to terminate this expression statement with a semicolon.

Axel

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20131104/72d67bf9/attachment-0001.html>


More information about the es-discuss mailing list