Javascript Array norepeat()

Description

Javascript Array norepeat()


Array.prototype.norepeat = function(){
  var result = [];
  for(var i=0;i<this.length;i++){
    if(result.indexOf(this[i]) == -1){
      result.push(this[i]);/*from  w  ww.ja  v a  2 s .  c  o  m*/
    }
  }
  return result;
};
[2,3,3,4,5,5].norepeat();



PreviousNext

Related