Array by copy
Newly available since 2023-07-04 (baseline low)
The toReversed()
, toSorted()
, toSpliced()
, and with()
methods of arrays and typed arrays return changed copies of arrays. They stand in contrast to methods such as sort()
or reverse()
that change arrays in place.
Compatibility
- Chrome 110 Released on 2023-02-07
- Chrome Android 110 Released on 2023-02-07
- Edge 110 Released on 2023-02-09
- Firefox 115 Released on 2023-07-04
- Firefox for Android 115 Released on 2023-07-04
- Safari 16 Released on 2022-09-12
- Safari on iOS 16 Released on 2022-09-12
MDN docs
Specifications
- https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.toreversed
- https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.tosorted
- https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.tospliced
- https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.with
- https://tc39.es/ecma262/multipage/indexed-collections.html#sec-%25typedarray%25.prototype.toreversed
- https://tc39.es/ecma262/multipage/indexed-collections.html#sec-%25typedarray%25.prototype.tosorted
- https://tc39.es/ecma262/multipage/indexed-collections.html#sec-%25typedarray%25.prototype.with