.reverse()

codewithfan5 total contributions
Published Jun 21, 2021Updated Jun 1, 2023
Contribute to Docs
Reverses the order of the elements of an array in place and returns the reversed array.
Syntax
The reverse()
method does not take any parameters.
array.reverse();
Example
Reverse the elements in an array:
const numbers = [5, 2, 9];numbers.reverse();console.log(numbers);
This results in the following output:
[9, 2, 5]
Codebyte Example
The following example below uses .reverse()
on an array, sports
, to reverse the order of the elements.
All contributors
- codewithfan5 total contributions
- christian.dinh2481 total contributions
- Anonymous contributorAnonymous contributor3077 total contributions
- Anonymous contributorAnonymous contributor92 total contributions
- codewithfan
- christian.dinh
- Anonymous contributor
- Anonymous contributor
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.