-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
Description
"Change Array by Copy" is a stage 4 proposal, which means it's ready to come out in the next edition of the ECMAScript standard and is in the current draft. It brings along four new methods for Array.prototype:
Array.prototype.toReversed() -> Array, returns a reversed version of a shallow copy of the array, leaving the original array intactArray.prototype.toSorted(compareFn) -> Array, returns a sorted version of a shallow copy of the array, leaving the original array intactArray.prototype.toSpliced(start, deleteCount, ...items) -> Array, returns a spliced version of a shallow copy of the array, leaving the original array intactArray.prototype.with(index, value) -> Array, returns a version of a shallow copy of the array, modified at the specific index, leaving the original array intact
as well as three new methods for TypedArray.prototype:
TypedArray.prototype.toReversed() -> TypedArray, see aboveTypedArray.prototype.toSorted(compareFn) -> TypedArray, see aboveTypedArray.prototype.with(index, value) -> TypedArray, see above
According to their README.md, it has the following implementations
Firefox/SpiderMonkey, currently flagged
Safari/JavaScriptCore, shipping unflagged since Safari Tech Preview 146
Chrome/V8, shipping unflagged since Chrome 110
Ladybird/LibJS, shipping unflagged
./polyfill.js (minimalist reference implementation)
Reactions are currently unavailable