Ben Wiley therealbenwiley at
Tue Jul 10 03:42:52 UTC 2018

Hi ECMAScript folks,

I'm brand new to this process and I've drafted a proposal (and polyfill)
for a new Array.prototype.replace method. In the vein of Array concat,
String replace and the new Object rest spread, Array replace provides a way
to shallow clone an array and replace an element in a single statement.

Here's the GitHub repo, which outlines API, motivation, use cases,
alternatives, and polyfill usage:

Array replace shouldn't be considered an across-the-board substitute for
Array.prototype.splice (which mutates the array) and wouldn't be ideal for
performance critical applications handling very large arrays. It is well
suited for application logic where immutability is desired - a trend
growing in the Javascript community.

Most of the application areas of object rest spread composition syntax (for
building objects, not destructuring them) are also application areas for
Array.prototype.replace, when your object happens to be an array.

I'm looking forward to any feedback and I'd also love for a champion to
step in and help, if you think this is an ok idea.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list