> Le 28 nov. 2018 à 19:32, Simo Costa <[email protected]> a écrit :
>
> In costructor functions and in the constructor() method in ES6 classes is
> easily to fall in the following pattern:
>
> F(par1, par2, ..., parN) {
> this.par1 = par1;
> this.par2 = par2;
> ...
> this.parN = parN;
> }
>
> So my proposal is to avoid those repetitions by prefixing a dot . to each
> parameter:
> F(.par1, .par2, ..., .parN) {}
>
> Simple but quite useful. More info here:
> https://github.com/jfet97/proposal-fast-this-assignments
> <https://github.com/jfet97/proposal-fast-this-assignments>
>
Simple, but a brand new and nonobvious syntax, for a relatively limited use
case.
Also, just one dot is too inconspicuous. At the very least, I’d prefer:
```js
function F(this.par1, this.par2, this.par3) { }
```
whose meaning is somewhat more intuitive.
Also noteworthy: in many cases, you can already reduce repetition with the
combination of `Object.assign`, improved syntax literal, and imagination; see:
http://2ality.com/2014/12/es6-oop.html#use-cases-for-objectassign
—Claude
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss