Nodejs Array Delete deleteRepeat()

Here you can find the source of deleteRepeat()

Method Source Code

Array.prototype.deleteRepeat = function(){
   var arr = this, 
      result=[], /*from  ww  w . j a  v a  2s.co m*/
      flag; 
   for(var i=0;i<arr.length;i++){
      flag=true;
      for(var j=0;j<result.length;j++){
         if(result[j]===arr[i]){
            flag=false;
            break;
         }
      }
      if(flag)result.push(arr[i]);
   }
   return result;
}

Related

  1. del(index)
    Array.prototype.del = function(index){
        if(isNaN(index) || index > this.length || index < 0){
            return false;
        this.splice(index,1);
    
  2. del(n)
    Array.prototype.del=function(n) {
      if(n<0){
        return this;
      }else{
        return this.slice(0,n).concat(this.slice(n+1,this.length));
    
  3. deleteSame()
    function JsonSort(json,key){
        for(j=1;j < json.length;j++){
            var temp = json[j],
                val  = temp[key],
                i    = j-1;
            while(i >=0 && json[i][key]>val){
                json[i+1] = json[i];
                i = i-1;
            json[i+1] = temp;
        return json;
    Array.prototype.deleteSame = function(){
      var res = [this[0]];
      for(var i = 1; i < this.length; i++){
        var repeat = false;
        for(var j = 0; j < res.length; j++){
          if(this[i] == res[j]){
            repeat = true;
            break;
        if(!repeat){
          res.push(this[i]);
      return res;
    
  4. trim(deleteValue)
    Array.prototype.trim = function(deleteValue) {
      var i;
      for (i = 0; i < this.length && this[i] == deleteValue;) {
        this.splice(i, 1);
      for (i = this.length-1; i >= 0 && this[i] == deleteValue; --i) {
        this.splice(i, 1);
      return this;
    ...