The Optional Chaining Operator returns undefined if an object is null or undefined, rather than throwing an error.
const car = {type:“Fiat”, model:“500”, color:“white”}; let name = car?.name; |
The ?.= operator has been supported in all modern browsers since March 2020.
The Logical AND Assignment Operator is used between two values; if the first value is true, the second value is assigned.
let x = 10; x &&= 5; |
The &&= operator has been supported in all modern browsers since September 2020.
The Logical OR Assignment Operator is used between two values; if the first value is false, the second value is assigned.
let x = 10; x ||= 5; |
The ||= operator has been supported in all modern browsers since September 2020.
The Nullish Coalescing Assignment Operator is used between two values; if the first value is null or undefined, the second value is assigned.
let x; x ??= 5; |
The ??= operator has been supported in all modern browsers since September 2020.
The Promise.allSettled() method returns a single Promise that resolves after all promises in a given list have settled (either fulfilled or rejected).
// Create a Promise const myPromise1 = new Promise((resolve, reject) => { setTimeout(resolve, 200, “King”); }); // Create another Promise const myPromise2 = new Promise((resolve, reject) => { setTimeout(resolve, 100, “Queen”); }); // Settle All Promise.allSettled([myPromise1, myPromise2]).then((results) => results.forEach((x) => myDisplay(x.status)), ); |
Since March 2020, Promise.allSettled() has been supported in all modern browsers.