CodesJava

Easy learning with example program codes

TypedArray reverse() JavaScript

The Javascript TypedArray reverse() method reverses an array based on the index.

Syntax:

array.reverse()

Returns:
It returns the reversed array.

Example 1:

<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">   
var Jewels = ["DIAMOND","GOLD","PLATINUM","SILVER"];
var gems = Jewels.reverse();  
document.write(gems);  
</script>
</body>
</html>

Output:

SILVER,PLATINUM,GOLD,DIAMOND

Example 2:

<!DOCTYPE html>
<html>
<body>
<script type="text/javascript"> 
const testArray = new Uint8Array([21, 42, 53]);
testArray.reverse();
 
document.write(testArray);
 
</script>
</body>
</html>

Output:

53,42,21
Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status