1。让一个变量继承数组的方法。varOldArray=Array.prototype;varnewArray=Object.create(OldArray)2.覆盖这个变量的7个变异方法constmutationMethods=['push','pop','shift','unshift','splice','sort','reverse']mutationMethods.forEach((item)=>{letoldFun=OldArray[item]//console.log(oldFun)newArray[item]=function(...args){//console.log(this,item)让result=oldFun.apply(this,args)返回结果;}})3.让数组隐式继承新变量methodletarr=[]//通过隐式原型继承arrayMethodsarr。__proto__=新数组
