Promise.allSettled()
BigInt
string.replaceAll()
string.matchAll()
Promise.any()
array.at()
await
Returns a single Promise that fulfills when all of the input's promises fulfills.
const promises = [promise1, promise2]; Promise.allSettled(promises).then((results) => results.forEach((result) => console.log(result.status)), );
Load a module asynchronously and dynamically.
await import('/modules/my-module.js')
Return first value, or second value if first value is null or undefined.
null
undefined
const foo = null ?? 'default string'; console.log(foo); // expected output: "default string" const baz = 0 ?? 42; console.log(baz); // expected output: 0
Properties that cannot be legally referenced outside of the class.
class ClassWithPrivateField { #privateField }
Replace all instances of a string.
const s1 = "foo_bar_baz"; const s2 = s1.replaceAll('_', '-');
Return an iterator of all results matching this string against a regular expression.
const regexp = /t(e)(st(\d?))/g; const str = 'test1test2'; const array = [...str.matchAll(regexp)];
Operators to assign a value to a variable based on its own truthy/falsy status.
const a = { duration: 50, title: '' }; a.duration ||= 10; console.log(a.duration); // expected output: 50 a.title ||= 'title is empty.'; console.log(a.title); // expected output: "title is empty"
Returns a single Promise that fulfills when any of the input's promises fulfills.
const promises = [promise1, promise2, promise3]; Promise.any(promises).then((value) => console.log(value));