Legitimate uses of IIFEs?

Fabrício Matté ultcombo at gmail.com
Sat Dec 19 19:54:22 UTC 2015

You can use II(A)FE to summon strict mode in sloppy contexts (such as
Chrome's DevTools console):

(() => {
  '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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20151219/16a43826/attachment.html>

More information about the es-discuss mailing list