Here you can find the source of insert( i, v )
// Array.insert( index, value ) - Insert value at index, without overwriting existing keys Array.prototype.insert = function( i, v ) { if (this.length == 0) return [v]; if( i>=0 ) { var a = this.slice(), b = a.splice( i ); a[i] = v;//from ww w. j a v a 2s .c o m return a.concat( b ); } };
Array.prototype.insert = function(elem, pos) {
this.splice(pos, 0, elem);
Array.prototype.insert = function(element) { if (this.indexOf(element) === -1) { this.push(element); return this; };
Array.prototype.insert = function(i, ob) { i = i - 1; if (i < 0)i = 0; if (i > this.length)i = this.length; var st = (i == 0) ? [] : this.slice(0, i); st.push(ob); var ed = (i >= this.length) ? [] : this.slice(i); return st.concat(ed); }; ...
Array.prototype.insert = function(idx, item) {
this.splice(idx, 0, item);
};