Tutorials Point


  JavaScript Basics
  JavaScript Objects
  JavaScript Advanced
  JS Useful References
  JS Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

Javascript Array reverse() Method


previous next AddThis Social Bookmark Button


Advertisements

Description:

Javascript array reverse() method reverses the element of an array. The first array element becomes the last and the last becomes the first.

Syntax:

array.reverse();

Here is the detail of parameters:

  • NA

Return Value:

Returns the reversed single value of the array.

Example:

<html>
<head>
<title>JavaScript Array reverse Method</title>
</head>
<body>
<script type="text/javascript">
var arr = [0, 1, 2, 3].reverse();
document.write("Reversed array is : " + arr ); 
</script>
</body>
</html>

This will produce following result:

Reversed array is : 3,2,1,0 

To understand it in better way you can Try it yourself.



previous next Printer Friendly

Advertisements


  

Advertisements