Package array to the weighting function

/ * 
  Unipue: Function name 
  @params 
    ary [the Array] go heavy array 
  @return 
    [the Array] array after the de-duplication 
* / 
function UNIQUE (ary) { 
   the let obj = {};
 for (the let I = 0; I < ary.length; I ++ ) 
{ 
  Item the let = ary [I];
   IF ! (obj [Item] == undefined) 
{ 
 // ary.splice (I,. 1); 
 // i--; 
 // splice performance is not bad We recommended 
  ary [I] = ary [-ary.length. 1 ]; 
  ary.pop (); 
  I - ;
   Continue ; 
} 
  obj [Item] = Item; //Rather than obj.item = item, here is the value of the item as an attribute, while 
                             // non "item" as an attribute.  
}
   Return ary; 
}
/ * 
  Unipue: Function name 
  @params 
    ary [the Array] go heavy array 
  @return 
    [the Array] array after the de-duplication 
* / 
function UNIQUE (ary) { 
   the let obj = {};
 for (the let I = 0; I < ary.length; I ++ ) 
{ 
  Item the let = ary [I];
   IF ! (obj [Item] == undefined) 
{ 
 // ary.splice (I,. 1); 
 // i--; 
 // splice performance is not bad We recommended 
  ary [I] = ary [-ary.length. 1 ]; 
  ary.pop (); 
  I - ;
   Continue ; 
} 
  obj [Item] = Item; //Rather than obj.item = item, here is the value of the item as an attribute, while 
                             // non "item" as an attribute.  
}
   Return ary; 
}

 

Guess you like

Origin www.cnblogs.com/angle-xiu/p/11319321.html