Phương thức reverse() của TypedArray đảo ngược thứ tự các phần tử trong mảng kiểu.
Cú pháp
typedArray.reverse()
Ví dụ
<html> <head> <title>Ví dụ JavaScript</title> </head> <body> <script type="text/javascript"> var typedArray = new Int32Array([11, 5, 13, 4, 15, 3, 17, 2, 19, 8 ]); document.write("Mảng gốc: " + typedArray); document.write("<br>"); var result = typedArray.reverse(); document.write("Mảng đã đảo ngược: " + result); </script> </body> </html>
Kết quả
Mảng gốc: 11,5,13,4,15,3,17,2,19,8 Mảng đã đảo ngược: 8,19,2,17,3,15,4,13,5,11