Javascript Array reverse()

Introduction

Javascript array reverse() method reverses an array in place.

It returns the revered array.

a.reverse()

Reversing the elements in an array

const a = [1, 2, 3];/*  ww w .  ja va2s. c o  m*/

console.log(a); // [1, 2, 3]

a.reverse(); 

console.log(a); // [3, 2, 1]



PreviousNext

Related