(function () { Array.prototype.insertSort = function () { for (let i = 1; i < this.length; i++) { let temp = this[i]; let j = i; while (j > 0) { if (this[j - 1] > temp) { this[j] = this[j - 1]; } else { break; } j-- } this[j] = temp } return this }; [3, 4, 2, 9].insertSort(); })();