https://github.com/tc39/notes/tree/master/meetings/2021-04
* Proposal Summaries and Comments from April: https://spidermonkey.dev/blog/2021/05/10/tc39.html
* Complete Notes: https://github.com/tc39/notes/tree/master/meetings/2021-03
The quick version:
Error cause, a new proposal, also advanced to stage 3. Error cause will help developers be descriptive about the reason why a certain error occurred. You can use it in the following pattern:
throw new Error('Error message Text', { cause: anotherError });
This should help make debugging nested errors more efficient. In Firefox, we had a non-standard second argument that is no longer in use, but there are no issues around web compatibility, as our implementation took a number and this will be an object.
A new, exciting proposal is Module Fragments presented by Daniel Ehrenberg. Module Fragments would allow bundlers to target a browser format that may in the future make bundling and working with modules on the web easier and more efficient. This proposal adds syntax which will allow the definition of multiple modules in one file.
The quick version:In this TC39 meeting, the updates to JavaScript Classes around private state have moved to stage 4. Other proposals of note this meeting were proposals related to ArrayBuffers, notably resizable ArrayBuffers and a new proposal, introducing read-only ArrayBuffers and fixed views into ArrayBuffers. Read-only ArrayBuffers are not a new ArrayBuffer, but rather a way to freeze existing ArrayBuffers so that they are not modified accidentally. Fixed views into ArrayBuffers would have the goal of not exposing more than the intended view of an ArrayBuffer to a third party.
One of the interesting new proposals is Object.has or Object.hasOwn. This would supply developers with a convenient shorthand. The following:
let hasOwn = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
if (hasOwn(object, "foo")) {
console.log("has property foo");
}
could instead be written as:
if (Object.hasOwn(object, "foo")) {
console.log("has property foo")
}
This is a tricky corner case, and this would simplify things.
Pattern matching was brought back with an update. The proposal has a number of champions now, and a new effort to
cleanly define the syntax. The record/tuple champions brought a new proposal that would
help align how mutable and immutable structures have symmetry in their methods.
Learning more:
If you are new to the standards world and want to learn more about TC39, you can take a look at the process document [1], and this slide deck that I did to explain the process [2]. We have also built a repository explaining how TC39 works [3].
If you want a Mozilla-specific take, I am doing a stream explaining how to read the specification and how SpiderMonkey works [4]. You can follow SpiderMonkey news through our newsletter [5].
[1]: https://tc39.es/process-document/
[2]: https://docs.google.com/presentation/d/1q6pCJVwgYV19gbvNdLtwMnQ6vMZKdqZY-cQ6CE5yH8Y/edit#slide=id.gc6fa3c898_0_0
[3]: https://github.com/tc39/how-we-work
[4]: https://hacks.mozilla.org/2020/06/compiler-compiler-working-on-a-javascript-engine/
[5]: https://mozilla-spidermonkey.github.io/blog/