• Skip to main content
  • Skip to search
  • Skip to select language
HTML

Structure of content on the web

  • Web APIs

    Interfaces for building web applications

  • Learn
    • CSS

      Learn to style content using CSS

    • Overview

      A customized MDN experience

    • FAQ

      Frequently asked questions about MDN Plus

  • HTTP Observatory

    Scan a website for free

  • JavaScript
  • Array.prototype.toReversed()
      • Deutsch
      • 日本語
      • 한국어
      • Русский
      • 中文 (简体)

    In this article

    • Syntax
    • Description
    • Examples
    • Specifications
    • Browser compatibility
    • See also
    1. Array.from()
    2. Array[Symbol.species]
  • Instance methods
    1. Array.prototype.entries()
    2. Array.prototype.find()
    3. Array.prototype.flat()
    4. Array.prototype.indexOf()
    5. Array.prototype.map()
    6. Array.prototype.reduceRight()
    7. Array.prototype.some()
    8. Array.prototype.toReversed()
    9. Array.prototype.unshift()
    10. Array: length
    11. Function.prototype.bind()
    12. Function: displayName Non-standard
    13. Function.prototype.arguments Non-standard Deprecated
    14. Function.prototype.caller Non-standard Deprecated
  • Instance methods
    1. Object.prototype.__defineGetter__() Deprecated
    2. Object.prototype.__defineSetter__() Deprecated
    3. Object.prototype.__lookupGetter__() Deprecated
    4. Object.prototype.__lookupSetter__() Deprecated
    5. Object.prototype.toLocaleString()
    6. Object.prototype.__proto__ Deprecated
    7. copying counterpart of the reverse() method. It returns a new array with the elements in reversed order.

  • Syntax

    js
    toReversed()
    

    Parameters

    None.

    Return value

    A new array containing the elements in reversed order.

    Description

    The toReversed() method transposes the elements of the calling array object in reverse order and returns a new array.

    When used on sparse arrays, the toReversed() method iterates empty slots as if they have the value undefined.

    The toReversed() method is generic. It only expects the this value to have a length property and integer-keyed properties.

    Examples

    Reversing the elements in an array

    The following example creates an array items, containing three elements, then creates a new array that's the reverse of items. The items array remains unchanged.

    js
    const items = [1, 2, 3];
    console.log(items); / [1, 2, 3]
    
    const reversedItems = items.toReversed();
    console.log(reversedItems); / [3, 2, 1]
    console.log(items); / [1, 2, 3]
    

    Using toReversed() on sparse arrays

    The return value of toReversed() is never sparse. Empty slots become undefined in the returned array.

    js
    console.log([1, , 3].toReversed()); / [3, undefined, 1]
    console.log([1, , 3, 4].toReversed()); / [4, 3, undefined, 1]
    

    Calling toReversed() on non-array objects

    The toReversed() method reads the length property of this. It then visits each property having an integer key between length - 1 and 0 in descending order, adding the value of the current property to the end of the array to be returned.

    js
    const arrayLike = {
      length: 3,
      unrelated: "foo",
      2: 4,
    };
    console.log(Array.prototype.toReversed.call(arrayLike));
    / [4, undefined, undefined]
    / The '0' and '1' indices are not present so they become undefined
    

    Specifications

    Specification
    ECMAScript® 2026 Language Specification
    # sec-array.prototype.toreversed

    Browser compatibility

    See also

    • Polyfill of Array.prototype.toReversed in core-js
    • es-shims polyfill of Array.prototype.toReversed
    • Indexed collections guide
    • Array.prototype.reverse()
    • Array.prototype.toSorted()
    • Array.prototype.toSpliced()
    • Array.prototype.with()
    • TypedArray.prototype.toReversed()

    Help improve MDN

    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.","name":"Array by copy"}},"browserCompat":["javascript.builtins.Array.toReversed"],"pageType":"javascript-instance-method"}}

    Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

    Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant