Thursday, June 15, 2017

.unshift lets you put something at the beginning of an array in JavaScript the way .push would put something at the end

Per this, this is an example:

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.unshift("Lemon","Pineapple");

 
 

Which would make an array holding:

  1. Lemon
  2. Pineapple
  3. Banana
  4. Orange
  5. Apple
  6. Mango

No comments:

Post a Comment