var num =[2,5,7,11],targret=9,numa,ret=[];for(i=0;i<=num.length/2;i++){for(j=num.length;j>=num.length/2;j--){if(num[i]!= num[j]){if(num[i]+num[j]== targret){
numa= ret.push(i,j);}}}}
console.log(ret);
2.重构pop方法,要求实现和pop一样的效果
var nums=[2,5,7,11];Array.prototype.mypop=function(){if(this.length >1){var lastArray =this[this.length -1];this.length -=1;return lastArray;}else{returnundefined;}};var res = nums.mypop();
console.log(res, nums);
3.重构push方法,要求实现和push一样的效果
var nums =[2,5,7,11];Array.prototype.mypush=function(){for(i =0; i < arguments.length; i++)this[this.length]= arguments[i];returnthis.length;}
console.log(nums.mypush(1,'hello'))
console.log(nums);