On This Month in JavaScript
JS features that became Baseline newly available in January
14 features · 4 years
The navigator.serviceWorker.register() method accepts { type: "module" } to load scripts that use import and export. Also known as ECMAScript modules or ESM in service workers.
The Promise.try() static method returns a promise that takes a callback of any kind (returns or throws, synchronously or asynchronously) and wraps its result in a Promise.
The Array.fromAsync() static method copies items from an async iterable object to make a new array.
The flat() and flatMap() methods for arrays creates a new array such that each nested array item is concatenated into it.
Async generator functions (async function*) create iterators that return multiple promises, one after another, on-demand.
Asynchronous iterator objects, such as those returned by promises or generator functions, are iterable with the for await .. of loop.
The destructuring assignment syntax is a JavaScript expression that unpacks values from arrays, or properties from objects, into distinct variables.
The globalThis property accesses the global this value (and hence the global object itself) across environments.
Omit the binding parameter of a catch clause when you don't need information about the exception in a try ... catch statement.
The spread (...) syntax allows an iterable, such as an array or string, to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected.
The matchAll() method of strings matches a string against a regular expression and returns an iterator of all results, including capturing groups.
The trimStart() and trimEnd() methods of strings return a new string with whitespace removed from the beginning or end of the string.
Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded expressions, and special constructs called tagged templates.