Adrian Perez de Castro (2014-10-30T13:14:43.000Z)
On Thu, 30 Oct 2014 09:29:36 +0100, Florian Bösch <pyalot at gmail.com> wrote:

> The usecases:
>
> [...]
> 
> *3) Initializing an existing array with a repeated numerical value*
> 
> For audio processing, physics and a range of other tasks it's important to
> initialize an array with the same data.
> 
> for(var i=0; i<size; i++){ someArray[i] = 0; }

For this use case there is %TypedArray%.prototype.fill(), see:

  http://people.mozilla.org/~jorendorff/es6-draft.html#sec-%typedarray%.prototype.fill

JavaScript engines are expected to implement it at some point. For example
I am implementing this in V8, along with other new typed array methods. The
engines should be able to generate quite good code for uses of this function
and/or provide optimized versions relying on knowledge of the underlying
element type of the typed array they are applied to.

Cheers,

--
 ☺ Adrián
d at domenic.me (2014-11-18T23:16:51.076Z)
On Thu, 30 Oct 2014 09:29:36 +0100, Florian Bösch <pyalot at gmail.com> wrote:

> The usecases:
>
> [...]
> 
> *3) Initializing an existing array with a repeated numerical value*
> 
> For audio processing, physics and a range of other tasks it's important to
> initialize an array with the same data.
> 
> ```js
> for(var i=0; i<size; i++){ someArray[i] = 0; }
> ```

For this use case there is %TypedArray%.prototype.fill(), see:

http://people.mozilla.org/~jorendorff/es6-draft.html#sec-%typedarray%.prototype.fill

JavaScript engines are expected to implement it at some point. For example
I am implementing this in V8, along with other new typed array methods. The
engines should be able to generate quite good code for uses of this function
and/or provide optimized versions relying on knowledge of the underlying
element type of the typed array they are applied to.