手写数组pop方法 王东煜 2019-09-18 434 阅读1分钟 /*在数组的末尾删除一个元素*/Array.prototype.myPop = function(){ //this就是当前类的实例 let temp = this[this.length-1];//获取当前数组的最后一项 this.length--;//长度减一 return temp//返回减一后的数组}var ary = [1,5,8,6,2,4,3,7];ary.myPop();console.log(ary);