Proposal: Object gather in parameters lists

# Simo Costa (6 years ago)

This is a proposal to allow gathering one ore more specified arguments into one or more objects when a function is invoked. This proposal totally replace the previous: "faster this assignments in constructor functions". Simple example:

constructor(...this{par1, par2, par3}) {
  // constructor body
}

I'm not going to explain here all the details about this proposal. You can find them on GitHub following this link jfet97/tc39-proposal-object-gather where the proposal is widely discussed. There you will find all the nitty gritty details, with a suggestion for the transpilations.

Reasons:

  • Currently this type of gather is not allowed in JavaScript.
  • It allows us to directly map function arguments to object properties in a programmed order.
  • It provides a fast and unequivocal way to construct object using parameters that could be easily optimized by the engine.
  • It provides a fast and clean way to create common constructor functions.
  • Current solutions imply one or more of the following: changes to the function signature, useless objects creations, annoying identifiers repetitions or an additional function call.

The involvement of a TC39 champion would be really appreciated.