Netlify was particularly focused on how this release can help do more with serverless and edge functions, Lengstorf said.
“There are some pretty big (and somewhat controversial) inclusions such as top-level await, which is a welcome addition for many developers, but some experts see it as a footgun that will trip up devs who don’t know how it works under the hood,” Lengstorf said.
The top-level await feature will “delay the execution of current and parent modules until the imported module is loaded,” according to the ECMA 2022 language specification. It allows modules to use runtime values to determine dependencies and it can be used as a fallback for dependencies, according to the standard.
Lengstorf said that one thing he was happy to see was the .at() Method, which is now supported by Array, String, or TypedArray. This will support negative indexing of JS Arrays, which is something other programming languages already allow. It gives the ability to write arr[-1] instead of arr [arr.length-1], where negative numbers count backward from the last element, according to software engineer Brayan Arrieta’s blog.
Error Cause Features
Lengstorf also highlighted the introduction of a “cause” for thrown errors, saying it gives “library authors more pathways to create an excellent developer experience.”
In error.cause, the Error object and its subclasses now allow developers to specify which error caused the current exception, with the cause showing up in the stack trace and accessible via err.cause, according to the web developer Kai Wenzel’s synopsis of the standard changes.
“One feature that stands out is Error.cause,” Kowal told The New Stack. “ES2022 adds an idiom for expressing and inspecting serial causal dependency between errors, complementing AggregateError, which expresses causal dependency on parallel errors.”
These features together “enable reflection on error causality,” he said, which will eventually surface in developer tools. Couple that with libraries that will begin to take advantage of the ability to express error causality, and “developers will be more able to glean useful information about the root causes for failure.” Kowal added.
Support for User Interfaces Creation
Also critical: The update addressed two corrupted libraries that had malicious packages included in their original creation, Labunski said.
In the next iteration, Agoric would like to see Compartments support, Kowal said
“That is probably the most highly anticipated upcoming feature, where essentially all the date formatting — like what does it mean to take today’s date and subtract a month?” Wang said. There’s all sorts of complicated date logic, including formatting but also including like date math, … Sometimes it’s a little ambiguous.”