Here you can find the source of insertBefore(index, item)
// Insert an item in an array before the index passed. // Can throw "Index out of range" error. Array.prototype.insertBefore = function(index, item) { if (index > this.length - 1 || index < 0) { throw new Error("Index out of range"); }// w ww. j a v a 2 s . com this.splice(index, 0, item); };
Array.prototype.insertBefore = function (o, toInsert) { var inserted = false; var index = this.indexOf(o); if (index == -1) { return false; else { if (index === 0) { this.unshift(toInsert); ...