"Take props" from object

Dmitry Soshnikov dmitry.soshnikov at gmail.com
Thu Aug 20 04:22:27 UTC 2015

Hey guys,

>From an internal conversation, we've received a question, and as a follow
up, the proposal of "take needed props from an object".

Currently if you need to take some properties from an object, you'd do:

var foo = {x: bar.x, y: bar.y, z: bar.z};

With possible shorthand it even could be (I guess someone proposed this
already at some point):

var foo = {bar.x, bar.y, bar.z};

Sometimes one could also do with destructuring and shorhands, but these are
two actions

var {x, y, z} = bar;
var foo = {x, y, z};

And the "take props" operator combine those approaches, and may look like
an import statement from a module, just without the `import` keyword:

var foo = {x, y, z} from bar;

I personally liked this strawman, it smoothes the border between a module
and an object (which is also a module/namespace, from which we can "import"
needed "exports").

I haven't checked yet the grammar, seems should be fine from the first


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150819/0d09213e/attachment-0001.html>

More information about the es-discuss mailing list