Netlify has been particularly focused on how this release can help do more with serverless and edge functions, Lengstorf said.
“There are some pretty important (and somewhat controversial) inclusions such as the high-level wait, which is a welcome addition for many developers, but some pundits see it as a gun that will trip up developers who don’t know. how it works under the hood,” Lengstorf said.
The top-level wait function “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 as per the standard.
Lengstorf said 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 other programming languages already allow. It gives the possibility to write arr[-1] instead of arr [arr.length-1]where negative numbers count backwards from the last item, according to software engineer Brayan Arrieta’s blog.
Characteristics of the cause of the error
Lengstorf also pointed to the introduction of a “cause” for thrown errors, saying it gives “library authors more avenues to create a great development experience.”
In error.cause, the Error object and its subclasses now allow developers to specify which error caused the current exception, with the cause appearing in the stack trace and accessible via err.cause, according to the developer’s synopsis Kai Wenzel’s web of 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 dependence between errors, complementing AggregateError, which expresses causal dependence on parallel errors.”
These features together “enable thinking about error causation,” he said, that will eventually show up in developer tools. Add to that libraries that will begin to take advantage of the ability to express error causation, and “developers will be better able to glean useful insights into the root causes of failure.” Kowal added.
Support for creating user interfaces
Part of the update helps developers speed up UI creation and includes “incredibly popular” new UI widgets, said Baruch Labunski, CEO of SEO firm Rank Secure.
Also critical: The update affected two corrupted libraries that had malicious packages included in their original build, Labunski said.
In the next iteration, Agoric would like to see bucket support, Kowal said.
“This is probably the most anticipated upcoming feature, where basically all 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 date calculations,… Sometimes it’s a bit confusing.