Skip to content

Add Change Array by Copy methods #6670

@Samathingamajig

Description

@Samathingamajig

"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 intact
  • Array.prototype.toSorted(compareFn) -> Array, returns a sorted version of a shallow copy of the array, leaving the original array intact
  • Array.prototype.toSpliced(start, deleteCount, ...items) -> Array, returns a spliced version of a shallow copy of the array, leaving the original array intact
  • Array.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 above
  • TypedArray.prototype.toSorted(compareFn) -> TypedArray, see above
  • TypedArray.prototype.with(index, value) -> TypedArray, see above

According to their README.md, it has the following implementations

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions