Skip to content

Latest commit

 

History

History
69 lines (55 loc) · 1.62 KB

File metadata and controls

69 lines (55 loc) · 1.62 KB
title ms.custom ms.date ms.prod ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
reverse Method (JavaScript) | Microsoft Docs
01/18/2017
windows-client-threshold
devlang-javascript
language-reference
reverse
JavaScript
TypeScript
DHTML
arrays [Visual Studio], reversing elements
reverse method
transposing elements
02ab051b-79b8-4646-b502-381671e78c12
11
mikejo5000
mikejo
ghogen

reverse Method (JavaScript)

Reverses the elements in an Array.

Syntax

  
arrayObj.reverse()   

Parameters

arrayObj
Required. Any Array object.

Return Value

The reversed array.

Remarks

The required arrayObj reference is an Array object.

The reverse method reverses the elements of an Array object in place. It does not create a new Array object during execution.

If the array is not contiguous, the reverse method creates elements in the array that fill the gaps in the array. Each of these created elements has the value undefined.

Example

The following example illustrates the use of the reverse method.

var arr = new Array(0,1,2,3,4);   
var reverseArr = arr.reverse();  
document.write(reverseArr);  
  
// Output:  
// 4,3,2,1,0  
  

Requirements

[!INCLUDEjsv2]

See Also

concat Method (Array)