globalThis
globalThis is global value of this. In order to understand globalThis, lets understand this.
The value of this various based on the environment in which we put this. If we put this in Nodejs, the value of this is global, however Inside a webworker the value is self.
globalThis is an attempt to unify the different global terms. So instead of window, self or global, we cause globalThis from ES11.
Promise.allSettled()
This method ensures all promises are settled, which means either resolved or rejected. In the following 3 promises, second promise is rejecting.
Nullish Coalescing Operator(??)
In JavaScript, we use OR operator(||) to check a condition and assign a default value if it is not present. The problem this approach is it returns a falsy value i.e. empty string, 0, false, null and undefined.
Optional Chaining Operator(?)
In JavaScript, if you try to read a property, which does not exist, it will throw an error, cannot read property name of undefined. Previously you can handle this scenario like below.
user && user.profile && user.profile.name
However with Optional Chaining Operator(?), now we can do it with much cleaner approach.
user?.profile?.name
import()
ECMAScript modules are completely static: you must specify what you import and export at compile time and can’t react to changes at runtime. This has several advantages, especially in tooling.
Static structure of imports enforced syntactically in two ways. Consider
import * as aModule from './module.js';
Dynamic import module works little like this
import('./module.js')
.then(module => module.foo());
Important thing to know is that import() is an operator.
Dynamic imports can be used in following
- Load code on demand
- Conditionally load module
BigInt
BigInt is a build-in object that provides a way to represent whole numbers larger than 2⁵³-1, which is the largest number in JavaScript.
const bigInteger = 9007199254740991n
const bigIngeger2 = BigInt(9007199254740991)
The typeof BigInt is
typeof bigInteger === 'bigint' // true
typeof BigInt(32) === 'bigint' // true
Previous versions of ECMAScript
- ES2015 also ES6
- ES2016 also ES7
- ES2017 also ES8
- ES2018 also ES9
- ES2019 also ES10