Skip to content

Instantly share code, notes, and snippets.

@cyberstream
Created August 17, 2011 02:42
Show Gist options
  • Save cyberstream/1150700 to your computer and use it in GitHub Desktop.
Save cyberstream/1150700 to your computer and use it in GitHub Desktop.
Insert an item into an array at the given zero-based offset, positive or negative
function(i,o){r=this;o=(o==-1?r.length:(o<-1?o+1:o));return r.slice(0,o).concat(i).concat(r.slice(o,r.length))}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment