On Wed, Jul 25, 2018 at 10:45 PM, Mikkel Davis <mikk...@gmail.com> wrote: > I've seen proposals for syntax additions that give functionality > similar to lodash's "pick" utility. But I think it may be more > appropriate to add it as an Object utility in the same vein of
What I don't like about it being a utility function is the need to create an array of property names or similar. Syntax has its own issues, but I like Bob's proposal: https://github.com/rtm/js-pick-notation > The only other concise way to do this I can think of, using latest ES is > `(({first, age}) => ({first, age}))(person)`, which is quite undesirable, > for a variety of reasons. Just FWIW, you can avoid the function there, at the expense of a couple more in-scope identifiers: ```js const {first, age} = person, result = {first, age}; ``` or to avoid those stray identifiers: ```js let result; { const {first, age} = person; result = {first, age}; } ``` If/when `do` expressions: ```js const result = do { const {first, age} = person; ({first, age}); }; ``` None of which is pretty either. :-) -- T.J. Crowder
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss