Proposal: Object dotstructuring

# Simo Costa (6 months ago)

This proposal is also known as: Pick Notation, Extended Object Destructuring, Extended Dot Notation.
Inspired by Bob Myers' proposal released under MIT License.

This is a proposal to allow read and write operations on multiple objects' properties (symbols included), leveraging object destructuring syntax to support renaming and defaults. The suggested syntax would enable quick objects creation from existing objects, to create subsets, and quick properties merging/replacing. Simple example:

const source = {prop1: 42, prop2: 'foo', [Symbol.iterator]: .. };

const newObject = source.{prop1, [Symbol.iterator]};
newObject; // {prop1: 42,  [Symbol.iterator]: .. };

source; // {prop1: 42, prop2: 'foo', [Symbol.iterator]: .. };

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-dotstructuring where the proposal is widely discussed. There you will find all the nitty gritty details, with a suggestion for the transpilations.


Currently JavaScript syntax does not let us to pick one or more properties from an object to create a new one nor let us to merge only some chosen properties from an object to another. Object dotstructuring could be useful to easily create objects subsets and to merge/clone/replace chosen properties from an object to another. You can find more info on GitHub.

The involvement of a TC39 champion would be really appreciated.