JavaScript typedArray.reverse() Method
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.
Example:
javascript
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();
a = A.reverse();
b = B.reverse();
c = C.reverse();
d = D.reverse();
e = E.reverse();
console.log(a);
console.log(b);
console.log(c);
console.log(d);
console.log(e);
|
Output:
6, 5, 4, 3, 2, 1
20, 15, 10, 5
10, 8, 6, 4, 2
7, 5, 3, 1
Last Updated :
10 Feb, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...