Promise.allSettled()
string.replaceAll()
string.matchAll()
Promise.any()
array.at()
await
array.findLast()
error.cause
Object.hasOwn()
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));
Provides standard objects and functions for working with dates and times.
Returns the value of the last element that satisfies the testing function.
const array1 = [5, 12, 50, 130, 44]; const found = array1.findLast((element) => element > 45); console.log(found); // expected output: 130
Indicate the specific original cause of the error.
try { connectToDatabase(); } catch (err) { throw new Error('Connecting to database failed.', { cause: err }); }
const object1 = { prop: 'exists' }; console.log(Object.hasOwn(object1, 'prop')); // expected output: true
Store the start and end positions of each matched capture group.
const str1 = "foo bar foo"; const regex1 = /foo/dg; console.log(regex1.exec(str1).indices[0]); // Output: Array [0, 2]