So, let's say you want a new object containing only some of the properties
from another object.
For example, if I have the Object1 like this:
o1 = {
a: 1,
b: 2,
c: 3,
d: 4,
e: 5
}
And I want another object containing Object1's *b*, *c*, and *e*.
I could:
o2 = {...o1} // a full copy of o1
o2 = { b: o1.b, c: o1.c, e: o1.e} // works, but is "boring" :p
let {b, c, e} = o // will create variables, instead of an o2 with the
properties
I think we could have a shorthand syntax that would be a combination of the
syntaxes we already have. Something like:
*o2 = {*
* [b, c, e]: ...o1*
*}*
Or, perhaps:
*o2 = {b, c, e}...o1*
Is there another way we can already accomplish it with a modern syntax?
Regards.
[ ]s
*--*
*Felipe N. Moura*
Web Developer, Google Developer Expert
<https://developers.google.com/experts/people/felipe-moura>, Founder of
BrazilJS <https://braziljs.org/> and Nasc <http://nasc.io/>.
Website: http://felipenmoura.com / http://nasc.io/
Twitter: @felipenmoura <http://twitter.com/felipenmoura>
Facebook: http://fb.com/felipenmoura
LinkedIn: http://goo.gl/qGmq
---------------------------------
*Changing the world* is the least I expect from myself!
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss