add something to the start of an array with unshift

unshift is the opposite of push where push adds to the end of an array unshift will add to the start of the array.


var my_array = [ ["dog", 2],["fish", 3] ];
my_array.unshift(["cat", 1]);
console.log("the array: "+my_array);


Other Items in javascript
Page Views

This page has been viewed 146 times.

Search Code
Search Code by entering your search text above.

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.