guest271314 at gmail.com (2019-06-06T00:16:14.988Z)
A slightly briefer version of ```from```
```const from = (i,o={},...p)=>p.map(k=>i[k]&&(o[k]=i[k]))&&o```
Usage
```let obj = from(user.profile,{otherData:"otherdata"},"firstName","lastName")```
```let obj = from(user.profile,{},"firstName")```
and
```
let obj = {};
from(user.profile,obj,"firstName","lastName","not" /* not included if not property of input object */);
```guest271314 at gmail.com (2019-06-06T00:05:21.089Z)
A slightly briefer version of ```from```, which could be set as
```Object.from``` for disambiguation
```const from = (i,o={},...p)=>p.map(k=>i[k]&&(o[k]=i[k]))&&o```
Usage
```let obj = from(user.profile,{otherData:"otherdata"},"firstName","lastName")```
```let obj = from(user.profile,{},"firstName")```
and 
```
Object.from = from; 
let obj = {};
Object.from(user.profile,obj,"firstName","lastName","not" /* not included if not property of input object */);
```guest271314 at gmail.com (2019-06-06T00:01:16.450Z)
A slightly briefer version of ```from```, which could be set as
```Object.from```
```const from = (i,o={},...p)=>p.map(k=>i[k]&&(o[k]=i[k]))&&o```
Usage
```let obj = from(user.profile,{otherData:"otherdata"},"firstName","lastName")```
```let obj = from(user.profile,{},"firstName")```
and 
```
Object.from = from; // for disambiguation
let obj = {};
Object.from(user.profile,obj,"firstName","lastName","not" /* not included if not property of input object */);
```guest271314 at gmail.com (2019-06-05T23:49:45.526Z)
A slightly briefer version of ```from```, which could be set as
```Object.from```
```const from = (i,o={},...p)=>p.map(k=>i[k]&&(o[k]=i[k]))&&o```
Usage
```let obj = from(user.profile,{otherData:"otherdata"},"firstName","lastName")```
and
```
Object.from = from;
let obj = {};
Object.from(user.profile,obj,"firstName","lastName","not" /* not included if not property of input object */);
```
A slightly briefer version of ```from```, which could be set as ```Object.from``` ```const from = (i,o={},...p)=>p.map(k=>i[k]&&(o[k]=i[k]))&&o``` Usage ```let obj = from(user.profile,{otherData:"other data"},"firstName","lastName")``` and ``` Object.from = from; let obj = {}; Object.from(user.profile,obj,"firstName","lastName","not" /* not included if not property of input object */); ``` On Sun, May 26, 2019 at 1:40 PM Григорий Карелин <grundiss at gmail.com> wrote: > Wouldn't it be nice to have syntax like this: > const obj = { {firstName, lastName from user.profile}, otherData: 'other > data' }; > as a syntactic sugar for > const obj = {firstName: user.profile.firstName, lastName: > user.profile.lastName, otherData: 'other data'}; > > Of cause at the moment we can write it in two steps: > const {fistName, lastName} = userProfile; > const obj = {firstName, lastName, otherData: 'other data'} > > But why use extra variables? > > Motivating example is lodash's .pick() method: > https://lodash.com/docs/#pick > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190605/ae345c38/attachment.html>