Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

TypeScript Array reverse() Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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




// Driver code
var arr = [ 11, 89, 23, 7, 98 ]; 
 
// use of reverse() method 
var val = arr.reverse();
   
// printing
console.log( val );


Output: 

[ 98, 7, 23, 89, 11 ]

Example 2: 

TypeScript




// Driver code
var arr = [2, 5, 6, 3, 8, 9]; 
var val;
   
// use of reverse() method 
val = arr.reverse();
val = val.reverse();
   
// printing
console.log( val );


Output: 

[ 2, 5, 6, 3, 8, 9 ]

 

My Personal Notes arrow_drop_up
Last Updated : 03 Jan, 2023
Like Article
Save Article
Similar Reads
Related Tutorials