如題,包括實現pop push 的返回值
不用數組操作方法實現數組的`pop`、`push` 方法
Qyouu
2018-08-19 14:13:01
TA貢獻1843條經驗 獲得超7個贊
Array.prototype._push = function(item) {
this[this.length] = item;
return this.length;
}
Array.prototype._pop = function() {
if (this.length === 0) return void 0;
var temp = this[this.length - 1];
this.length--;
return temp;
}
舉報