push() 方法可向数组的末尾添加一个或多个元素,并返回新的长度。
// 方法一 Array.prototype._push = function(){
for(let i = 0;i< arguments.length;i++){
this[this.length] = arguments[i]
}
return this.length
}
//方法二: 借用splice
Array.portotype._push1 = function(){
for(let i = 0;i< arguments.length;i++){
this.splice(this.length,0,arguments[i])
}
return this.length
}