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.
Living Standard  

Compatibilitate browser

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support1 Yes15.5 Yes Yes
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidIE mobileOpera AndroidiOS Safari
Basic support Yes Yes Yes4 Yes Yes Yes

Vezi si

Document Tags and Contributors

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