ES2020 Cool Stuff Reminder
As a small self-reminder, here are some useful features of the upcoming useful additions in ES2020 in my opinion.
Optional Chaining (?.)
const user = { name: "Foo" }
user.settings && user.settings.theme => undefined
user.settings?.theme => undefned
Nullish Coalescing Operator (??)
Returns right hand when false
const username = user && user.name ? user.name : 'anonymous'
const username = user && user.name ?? 'anonymous'
// Even simpler with optional chaining
const username = user?.name ?? 'anonymous'
MDN Nullish Coalescing Operator
Dynamic Import (await import)
Supports async/await
!
async somethingAsync() => {
await import ('./widgets/big-async-widget')
}