5 ms·
Interesting, what is your use case for that?
by dbbk 6y ago
Interesting, what is your use case for that?
- thitcanh 6y agoThe use case is that it exists: It’s already been vetted and it’s part of the language. Not supporting it means you don’t support the entire language.
- sknowieowl 6y agoIt's part of the language, but not so much thoroughly vetted. The Chrome/V8 implementation has bugs. https://github.com/evanw/esbuild/issues/253#issuecomment-773785579 https://github.com/evanw/esbuild/issues/253#issuecomment-773...
- thitcanh 6y agoI mean the feature itself has been vetted, i.e. it wouldn’t be in the language if enough people didn’t find it reasonably useful. TLA is a substantial feature implementation-wise so I expect TC39 to have thought “yeah that’s still worth it”
- sknowieowl 6y agoTLA was accepted in the specification before the module loading scenarios were fully baked. Probably best to use async IIFEs until the TLA spec bugs are sorted out and the fixes are subsequently implemented in the major browsers and released. Maybe a year from now.
- ratww 6y agoThe use case is not needing to wrap your code in an IIFE [1] when you would have a top-level await statement. It is useful in entry point of apps where you might need anything that uses async. It's also useful for having async modules. [2] They're also very helpful for debugging. Using await something in the console is way more convenient than something.then(). [1] https://developer.mozilla.org/en-US/docs/Glossary/IIFE https://developer.mozilla.org/en-US/docs/Glossary/IIFE [2] https://github.com/tc39/proposal-top-level-await/blob/HEAD/README.md https://github.com/tc39/proposal-top-level-await/blob/HEAD/R...