<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
<script>
//为数组添加方法
Array.prototype.remove = function(index)//0<index<arr.length
{
var iLen = this.length;
for(var i = 0; i < iLen; i++)
{
if(i == index){ continue;}
this.push(this[i]);
}
this.splice(0,iLen);
return this;
}
//封装的方法
function remove(arr,index)//arr为array;0<index<arr.length
{
var iLen = arr.length;
for(var i = 0; i < iLen; i++)
{
if(i == index){ continue;}
arr.push(arr[i]);
}
arr.splice(0,iLen);
return arr;
}
window.onload = function()
{
var arr = ['a','b','c','d'];
arr.remove(0).remove(0).remove(0).remove(0);
console.log(arr)
}
</script>
</body>
</html>