Skip to content

Instantly share code, notes, and snippets.

@duncanmcdougall
Created August 1, 2012 22:42
Show Gist options
  • Save duncanmcdougall/3231354 to your computer and use it in GitHub Desktop.
Save duncanmcdougall/3231354 to your computer and use it in GitHub Desktop.
Insert item to start of JavaScript array
var fruit = ["apple", "banana", "coconut"];
fruit.reverse().push("melon");
fruit.reverse();
//fruit array should now be ["melon", "apple", "banana", "coconut"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment