Array.prototype.reverse()
Method reverse()
membalikkan urutan array elemen. Elemen array pertama menjadi terakhir dan sebaliknya.
Sintaks
arr.reverse()
Parameter
None.
Deskripsi
Method reverse
mengubah urutan elemen objek array, memutasi array, dan mengembalikan referensi ke array.
Contoh
Membalikan elemen di dalam array
Pada contoh membuat array myArray
dengan tiga elemen, kemudian membalikkan array.
var myArray = ['one', 'two', 'three'];
myArray.reverse();
console.log(myArray) // ['three', 'two', 'one']
Spesifikasi
Spesifikasi | Status | Comment |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard | Initial definition. Implemented 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 (ECMA-262) The definition of 'Array.prototype.reverse' in that specification. |
Living Standard |
Kompabilitas browser
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help! (en-US)
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 1.0 | 1.0 (1.7 or earlier) | 5.5 | (Yes) | (Yes) |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |