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'];
a.reverse(); 

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

Sintaxa

a.reverse()

Valoarea returnata

Array-ul inversat.

Descriere

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

Example

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

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.
Standard  
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'Array.prototype.reverse' in that specification.
Standard  
ECMAScript Latest Draft (ECMA-262)
The definition of 'Array.prototype.reverse' in that specification.
Draft  

Compatibilitate browser

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung 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

Legend

Full support  
Full support

Vezi si

Document Tags and Contributors

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