Tuesday, June 4, 2013

.reverse() in JavaScript

...reverses the order of an array as shown in this w3schools.com example:

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

 
 

This makes fruits like so:

  1. Mango
  2. Apple
  3. Orange
  4. Banana

 
 

Personally, I'd put the banana first not fourth. It seems like the array was shipshape to begin with.

No comments:

Post a Comment