Re: Array.prototype.repeat

2018-03-26 Thread Cyril Auburtin
> maybe fill with incrementing number? ```js Array.from({length: 6}, (_, i) => i) ``` > Are there use cases for filling with alternating values, as in `['x', 'y'].repeat(3)`? Not so many, but for example when working with flat matrices, `[0,0,255,1].repeat(len)` for generating quickly a uniform

Re: Array.prototype.repeat

2018-03-26 Thread Jerry Schulteis
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 wrote:

Re: Proposal: if variable initialization

2018-03-26 Thread Naveen Chawla
OK, but your example wouldn't be acceptable in JavaScript, because it's inconsistent with how `for(;;)` does initialization before the first `;`, which is before iteration. That's why I was saying that initializers-as-expressions simplifies doing things like that, despite the other concerns. On M

Re: partial spread syntax

2018-03-26 Thread Mike Samuel
On Sun, Mar 25, 2018 at 9:20 PM, 月の影 <19511...@qq.com> wrote: > Sometimes I got a infinity iterable sequences, I may want a partial spreed > syntax. `...iterableObject{from, to}` > How would you prevent ambiguity between the spread and blocks? iterable { from, to }; is currently equivalent to

Re: Fwd: Array additions

2018-03-26 Thread Sebastian Malton
All of those seem like they would be worth adding. However, if they do get added I think that since it would be so useful and it is very often requested a `forEachInline` function would be a good addition. It would function exactly like `forEach` except that the return value would be `this` inst