Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Which built-in method reverses the order of the elements of an array?

user-image
Question added by salma samreen , Quality Assurance Engineer , Private Limited
Date Posted: 2016/02/16
Kariem Soudy
by Kariem Soudy , Web Solutions Consultant , Tatweer Educational Transportation Services Company

reverse()use it like this$(selector).get().reverse()

Muhammad Muhammad Wakeel
by Muhammad Muhammad Wakeel , Web Developer , Dataocean

With Commons.Lang  you could simply use 

 

ArrayUtils.reverse(int[] array)

Most of the time, it's quicker and more bug-safe to stick with easily available libraries already unit-tested and user-tested when they take care of your problem.           

Prathmesh Agarwadekar
by Prathmesh Agarwadekar , web designer , EL Shaddai Charitable Trust

var array_name[4]={5,4,8,6};

array_name.reverse();

Sajith Kumar Cheruvachery Veettil
by Sajith Kumar Cheruvachery Veettil , Software Engineer , Ace Crane systems

var jqArray= ['1', '2', '3'];

var x=jqArray.reverse(); 

 

Result=['3','2','1']

Deleted user
by Deleted user

var firstArray = [1,2,3];

var result = firstArray.reverse();

result = [3,2,1]

Mohd Tariq Khan Tariq
by Mohd Tariq Khan Tariq , Web Developer , Prolines.sa

var arr= ["Banana", "Orange", "Apple", "Mango"];arr.reverse();

Mohamed Siddiqkhan Mohamed Jalaludeen
by Mohamed Siddiqkhan Mohamed Jalaludeen , PHP Developer , AWOk

var myArray = ['apple', 'orange', 'grape'];myArray.reverse();

Mobeen Khalid
by Mobeen Khalid , VP of Engineering , Lorryz

reverse() is a built on function to reverse the order of array.

Diyaiddin Bader
by Diyaiddin Bader , System Analyst / Programmer , EBTTIKAR TECHNOLOGY CO. LTD.

reverse()

 

Syntax

arr.reverse()

Parameters : none

Description :

The reverse method transposes the elements of the calling array object in place, mutating the array, and returning a reference to the array.

Examples

 

var myArray = ['one', 'two', 'three'];

myArray.reverse(); 

console.log(myArray) // ['three', 'two', 'one']

hoda elboray
by hoda elboray , builder , GIT

reverse () Reverse the order of the elements in an array

Sukhdev Kushwaha
by Sukhdev Kushwaha , Sr. Programmer , Ugam Solutions Pvt. Ltd, Goregaon

reverse() function is used to reverse an array data.

More Questions Like This