This translation is incomplete. Please help translate this article from English.

Metoda reverse() inverseaza un array in ceea ce priveste pozitia elementelor. Primul element din array devine ultimul, iar ultimul element din array devine primul.

var a = ['A', 'B', 'C'];

console.log(a); // ['C', 'B', 'A']



Valoarea returnata

Array-ul inversat.


Metoda reverse transpune elementele array-ului in ceea ce priveste pozitia, modificand array-ul,  returnand o referinta la acel array.


Inversarea elementelor in array

Urmatorul exemplu creaza un array - a, care contine trei elemente, dupa care inverseaza array-ul. Apelarea metodei reverse() returneaza o referinta la la array-ul inversat a.

var a = ['A', 'B', 'C'];
var reversed = a.reverse(); 

console.log(a);        // ['C', 'B', 'A']
console.log(reversed); // ['C', 'B', 'A']


Specificatii Status Info
ECMAScript 1st Edition (ECMA-262) Standard Initial definit. Implementat in JavaScript 1.1.
ECMAScript 5.1 (ECMA-262)
The definition of 'Array.prototype.reverse' in that specification.
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'Array.prototype.reverse' in that specification.
ECMAScript Latest Draft (ECMA-262)
The definition of 'Array.prototype.reverse' in that specification.

Compatibilitate browser

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
Basic supportChrome Full support 1Edge Full support YesFirefox Full support 1IE Full support 5.5Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes


Full support  
Full support

Vezi si

Document Tags and Contributors

Contributors to this page: andreiTn
Last updated by: andreiTn,