Get distinct value from array - Node.js Array

Node.js examples for Array:Array Value

Description

Get distinct value from array

Demo Code


Array.prototype.distinct = function (){
      var ret = [];
      for(var i=0;i<this.length;i++){
        if(this.indexOf(this[i])!=i){
            ret.push(this[i]);//from  w w  w  .j a v  a2s.  co m
        }
      }
      return ret;
  }
console.log(['a','b','c','d','b','"a"','e','1','2','3','2','"3"'].distinct());

Related Tutorials