利用JavaScript重构数组的pop方法 实现底层逻辑 Array.prototype.myPop = function () { if (this.length > 0) { var last = this[this.length - 1] this.length = this.length - 1 return last } else { return undefined; } } var arr = [1, 2, 3, 4, 5] var res = arr.myPop() console.log(res,arr);