Array.prototype._reverse = function() { const len = this.length; const mid = Math.floor(len / 2); // l: left pointer; r: right pointer; let l = 0, r = len - 1, temp; while (l <= mid || r >= mid) { temp = this[l]; this[l] = this[r]; this[r] = temp; l++; r--; } };
代码有不当处,望指正