TypeScript Array reverse() Method
Last Updated :
03 Jan, 2023
The Array.reverse() is an inbuilt TypeScript function which is used to reverses the element of an array.
Syntax:
array.reverse();
Parameter: This methods does not accept any parameter.
Return Value: This method returns the reversed single value of the array.
Below examples illustrate the Array reverse() Method in TypeScript.
Example 1:
TypeScript
var arr = [ 11, 89, 23, 7, 98 ];
var val = arr.reverse();
console.log( val );
|
Output:
[ 98, 7, 23, 89, 11 ]
Example 2:
TypeScript
var arr = [2, 5, 6, 3, 8, 9];
var val;
val = arr.reverse();
val = val.reverse();
console.log( val );
|
Output:
[ 2, 5, 6, 3, 8, 9 ]
Share your thoughts in the comments
Please Login to comment...