List of utility methods to do Array Insert Before
insertBefore(index, item)Array.prototype.insertBefore = function(index, item) { if (index > this.length - 1 || index < 0) { throw new Error("Index out of range"); this.splice(index, 0, item); }; | |
insertBefore(o, toInsert)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); ... |