I am looking for a JavaScript array insert method, in the style of:
arr.insert(index, item)
Preferably in jQuery, but any JavaScript implem
i like little safety and i use this
Array.prototype.Insert = function (item, before) { if (!item) return; if (before == null || before < 0 || before > this.length - 1) { this.push(item); return; } this.splice(before, 0,item ); } var t = ["a","b"] t.Insert("v",1) console.log(t )