Modern JavaScript ES2020: Top Features You Should Know
ECMAScript 2020 added practical features that reduce boilerplate and improve null-safety. If you are still avoiding optional chaining, now is the time to adopt it.
Optional Chaining and Nullish Coalescing
const city = user?.address?.city ?? 'Unknown';
?. short-circuits on null or undefined. ?? returns the right side only when the left is null or undefined-unlike ||, it preserves 0 and ''.
BigInt and globalThis
BigInt handles integers beyond Number.MAX_SAFE_INTEGER. globalThis provides a standard way to access the global object in browsers and Node.
Promise.allSettled
Wait for all promises regardless of failure-useful for batch operations where partial success is acceptable:
const results = await Promise.allSettled([
fetch('/api/a'),
fetch('/api/b'),
]);
dynamic import()
const module = await import('./heavy-chart.js');
module.renderChart(data);
Enables code splitting without bundler-specific syntax.
Conclusion
ES2020 features are supported in all modern browsers and Node LTS. Enable them in TypeScript with an appropriate target and let Babel or esbuild downlevel only when you must support legacy clients.