Legitimate uses of IIFEs?

Caitlin Potter caitpotter88 at gmail.com
Sat Dec 19 20:01:06 UTC 2015


Note that currently, you can't set the language mode in a do-expression. Of course that could change, i think they're wanting to change a bunch of other things already.

> On Dec 19, 2015, at 2:54 PM, Fabrício Matté <ultcombo at gmail.com> wrote:
> 
> You can use II(A)FE to summon strict mode in sloppy contexts (such as Chrome's DevTools console):
> 
> ```js
> (() => {
>   'use strict';
>   // ...
> })();
> ```
> 
> This is useful as Chrome either does not implement or uses legacy semantics for quite a few ES2015 features in sloppy mode (e.g. let, const).
> 
> As for real code you would write, seeing as ECMAScript modules are implicitly strict and we should have do-expressions soon, I don't see much use for IIFEs anymore.
> 
> /fm
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss


More information about the es-discuss mailing list