ES2021 is going to land soon 🚀
It's gonna be really exciting.
Meanwhile - are you fully up to speed with all the cool things we got from ES2020?
Let's take a look at a few of them here 🧵 👇
⚡ Dynamic import
With this new feature, we can import JavaScript modules dynamically, as we need it.
This pattern is also known as code-splitting, and with ES2020 we can do this natively instead of relying on tools like Webpack.
⚡ Optional Chaining
With this feature, we can now access deeply nested properties without having to null-check.
Notice how 'quxBaz' becomes undefined instead of throwing a reference error.
⚡ Nullish Coalescing
With Nullish Coalescing, we can now evaluate values that are 'nullish', not just 'falsy'.
Notice how the variable 'foo' is falsy, but not nullish (null or undefined).
In some cases, we want to use fallbacks only in the case of null or undefined.
⚡ globalThis
If you want to reuse code across different runtimes, you'll run into trouble with the global object.
globalThis will reference 'window' in browsers, 'global' in Node.js, and 'self' in Web Workers.
Now we don't have to manually detect the runtime anymore.