Whatever the use cases might be, I like generators and spread for filling an 
array with values, e.g.:
```jsfunction* repeat(n, ...values) {  for (let i = 0; i < n; ++i) {    yield* 
values;  }}
[...repeat(3, 'x', 'y')]
```


    On Sunday, March 25, 2018, 3:41:10 PM CDT, Claude Pache 
<[email protected]> wrote:  
 
[...]
For filling a new array with one value, `Array(n).fill('foo')` seems reasonable 
to me.
Are there use cases for filling with alternating values, as in `['x', 
'y'].repeat(3)`?
  
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to