I think the main reason that destructing assignment was implemented
was that you had to create a new declaration for each variable, and
possibly another temporary variable to refer to the source object.
However, this isn't as much of an issue with object properties. I
don't think it'd be too hard to create a function that does that
today, e.g.
```
function foo(obj, props) {
const ret = {};
for (let i of props) ret[i] = obj[i];
return ret;
}
let X = foo({ a: 1, b: 2, c: 3 }, [ 'a', 'b' ]);
```
Obviously that's ignoring a few spec-level details, but that's the general idea.
Is there any other significant advantage that such a proposal would
bring? If not, I don't think this needs to be added as new syntax.
--
- Karl Cheng (Qantas94Heavy)
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss