Le 08/03/2012 13:02, Maël Nison a écrit :
Hi,
I'm just wondering why there is no mutable function with Javascript
arrays.
For exemple, if I want to remove every entry matching 42 from an
array, I will have to write something like :
> var array = [ 0, 1, 42, 3, 4, 5, 42, 42, 42 ];
> array = array.filter( function ( x ) { return x === 42; } );
Why is it necessary to make a copy ? Why can't we just write something
like this ?
> var array = [ 0, 1, 42, 3, 4, 5, 42, 42, 42 ];
> array.mfilter( function ( x ) { return x === 42; } ); // mutable filter
(...)
Is there a reason for these missing functions ?
None besides history.
It's still possible to add these functions to Array.prototype yourslef,
though.
David
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss