JavaScript | typedArray.reverse() with Examples
The typedArray.reverse() is an inbuilt function in JavaScript which is used to reverse the given typedArray elements i.e, first element becomes the last and vice versa.
Syntax:
typedArray.reverse();
Parameter: It does not accept any parameters.
Return value: It returns the new reversed typedArray.
JavaScript code to show the working of this function:
<script> // Creating some typedArrays with some elements const A = new Uint8Array([ 1, 2, 3, 4, 5, 6 ]); const B = new Uint8Array([ 5, 10, 15, 20 ]); const C = new Uint8Array([ 2, 4, 6, 8, 10 ]); const D = new Uint8Array([ 1, 3, 5, 7 ]); const E = new Uint8Array(); // Calling reverse() function on the above typedArray a = A.reverse(); b = B.reverse(); c = C.reverse(); d = D.reverse(); e = E.reverse(); // Printing the reversed typedArray document.write(a + "<br>" ); document.write(b + "<br>" ); document.write(c + "<br>" ); document.write(d + "<br>" ); document.write(e); </script> |
chevron_right
filter_none
Output:
6, 5, 4, 3, 2, 1 20, 15, 10, 5 10, 8, 6, 4, 2 7, 5, 3, 1
Recommended Posts:
- JavaScript | addEventListener() with Examples
- JavaScript | console.log() with Examples
- JavaScript | _.reduceRight() with Examples
- JavaScript | typedArray.every() with Examples
- Javascript | _.reduce() with Examples
- JavaScript | typedArray.name with Examples
- JavaScript | weakSet.add() with Examples
- JavaScript | weakMap.set() with Examples
- JavaScript | typedArray.from() with Examples
- JavaScript | weakMap.has() with Examples
- JavaScript | typedArray.of() with Examples
- JavaScript | weakSet.has() with Examples
- JavaScript | unescape() with examples
- JavaScript | getPrototypeOf() with Examples
- JavaScript | uneval() with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.