js 有关数组查询,删除,唯一等操作集合 整理

//  indexOf

Array.prototype.indexOf = function(e){
    for(var i=0,j; j=this[i]; i++){
        if(j==e){return i;}
    }
    return -1;
}


// delete

Array.prototype.remove = function(from, to) {
    var rest = this.slice((to || from) + 1 || this.length);
    this.length = from < 0 ? this.length + from : from;
    return this.push.apply(this, rest);
};

// unquie

Array.prototype.unquie=function(){
        var newArray=new Array();
        var len=this.length;
        for (var i=0;i 
  


你可能感兴趣的:(jsp)