Pick operator

Bergi a.d.bergi at web.de
Mon Jun 22 21:51:33 UTC 2015

Bob Myers schrieb:
> In the spirit of the discussion about language complexity and
> extensibility, consider the following brain-addled, pre-strawman proposal
> for a new pick operator.
> http://rtm.github.io/boberator.html

Thanks, some quite interesting ideas!

Some quick thoughts while reading:
* `o && typeof o === 'object'` should just test for `o != null`. Or at 
least not ignore function objects.
* that array picker operator should be omitted. Nobody needs this, 
picking from an array is very rare. Just use the standard `#` picker 
operator, onto an array literal, with explicit property names if need be.
* Don't introduce a new syntax for computed properties, we have brackets 
already. That `*` looks to much like generator functions.

However, instead of introducing a new operator I'd rather like to extend 
destructuring and property shorthands to take more than single 
identifier. The basic examples from your motivation could easily handled 
by this, withoug looking much worse:

   let pickedObj = {o.p1, o.p2}; // uses "p1" and "p2" for property names

   {pickedObj.p3} = o; // takes "p3" as property name, assigns to LHS 


More information about the es-discuss mailing list