Extended dot notation is a proposal for a new syntax for picking properties
into objects. The canonical example is

```js
let o1 = { a: 1, b: 2};
let o2 = o1.{a};         // {a: 1}
```

You may think of this as deconstructing objects into objects, rather than
variables.

Syntactically, the extended dot notation is the dot followed by something
in curly braces. This avoids eating up another precious special symbol, yet
is unambiguous since at present only an identifier can follow a dot.

I've put together a short introduction at
https://github.com/rtm/js-pick-notation/blob/master/docs/intro.md. This
repository also contains a full spec at
https://github.com/rtm/js-pick-notation/blob/master/js-pick-notation.md.
The spec includes a section on motivation, which in a nutshell is
expressiveness and brevity. The repo also features a proof-of-concept
implementation using sweet.js.

A variant of the proposal uses `#` instead of `.`, the pros and cons of
which are discussed in the spec.

I won't repeat details from the introduction here, but there are more
features of interest, including picking into arrays, pickers as functions,
etc.

I'm looking for good feedback as well as a champion for this feature.

--
Bob Myers
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to