V8 adds support for top-level await
chromium.googlesource.com
V8 adds support for top-level await
1–10 of 310 posts
Re: V8 adds support for top-level await
#2This is huge! Finally no more need to use IIFE's for top level awaits
Re: V8 adds support for top-level await
#3This is huge! Finally no more need to use IIFE's for top level awaits
What is an IIFE?
Re: V8 adds support for top-level await
#4Re: V8 adds support for top-level await
#5This 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
#6Re: V8 adds support for top-level await
#7Now if only python would do the same.
Re: V8 adds support for top-level await
#8Re: V8 adds support for top-level await
#9This is huge! Finally no more need to use IIFE's for top level awaits
It's nice, I guess, but huge?
Instead of:
async function main() {
// code
}
main().catch(console.error);
I'll be maybe writing: try {
// code
} catch (ex) {
console.error(ex);
}
Hrm?Re: V8 adds support for top-level await
#10Is this part of the standard?