Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

Winton Welsh http://stu.dicio.us

« Newer Snippets
Older Snippets »
1 total  XML / RSS feed 

Insert Into Array

// insert item into array by specifying the array, insertion index - 1, and the item

insertArray: function(array, afterIndex, item) {
  var first = array.slice(0, afterIndex + 1);
  var second = array.slice(afterIndex + 1);
  first.push(item);
  return first.concat(second);
}
« Newer Snippets
Older Snippets »
1 total  XML / RSS feed