Live data from Hacker News

V8 adds support for top-level await

chromium.googlesource.com

1–10 of 310 posts

Re: V8 adds support for top-level await

#5

This is huge! Finally no more need to use IIFE's for top level awaits

What is an IIFE?

Immediately invoked function expression - aka an anonymous function that executes as it is interpreted.

    (function() { console.log('test'); })();
In old versions of JavaScript, variables had to be scoped to the nearest function (rather than the nearest block) so IIFE where often used for namespacing:

    var $ = (function() { this.version = '1.2.3'; })();
    $.version; // 1.2.3
This worked because the function would be immediately invoked upon interpretation, scoping it's contents to itself (aliased by the variable name).

Re: V8 adds support for top-level await

#6

This is huge! Finally no more need to use IIFE's for top level awaits

What is an IIFE?

he should have said IIAFE actually (immediately-invoked-async-function-expression)

  (async () => { console.log(await 'hello world') })()
Post reply on HN