Nodejs Array Unique unique(callback)

Here you can find the source of unique(callback)

Method Source Code

Array.prototype.unique = function(callback) {
  var o = {}, i, l = this.length, r = [];
  for (i=0; i<l; i+=1) {
    var val = callback(this[i]);
    o[val] = this[i];/*from  w w  w. ja v  a 2s  .  c o m*/
  }
  for (i in o) {
    r.push(o[i]);
  }
  return r;
};

Related

  1. unique(a)
    Array.prototype.unique = function(a) {
        return function(){return this.filter(a)}}(function(a,b,c){return c.indexOf(a,b+1)<0
    });
    
  2. unique(a)
    x = ''
    Array.prototype.unique=function(a){
      return function(){return this.filter(a)}}(function(a,b,c){return c.indexOf(a,b+1)<0
    });
    function getCombi(vect,res,n,r){
       if(n == 0){
          x = x + res +":";
       }else{
          for(var i = 0; i < r; i++){
    ...
    
  3. unique(a)
    Array.prototype.unique = function(a) {
        return function(){return this.filter(a)}}(function(a,b,c){return c.indexOf(a,b+1)<0
    });
    
  4. unique(b)
    Array.prototype.unique = function(b) {
        var a = [], i, l = this.length;
        for (i = 0; i < l; i++) {
            if (a.indexOf(this[i], 0, b) < 0) {
                a.push(this[i]);
        return a;
    };
    ...
    
  5. unique(b)
    Array.prototype.unique = function(b) {
      var a = [], i, l = this.length;
      for (i = 0; i < l; i++) {
        if (a.indexOf(this[i], 0, b) < 0) {
          a.push(this[i]);
      return a;
    };
    ...
    
  6. unique(data)
    Array.prototype.unique = function(data) {
      data.sort();
      var re = [ data[0] ];
      var length = data.length;
      for (var i = 1; i < length; i++) {
        if (data[i] !== re[re.length - 1]) {
          re.push(data[i]);
      return re;
    };
    
  7. unique(fun, map)
    (
      Array.prototype.unique = function (fun, map) {
        fun = fun || (function(c) { return c; });
        var arrayUnique = [this[0]], 
        arrayUniqueAtt = [fun(this[0])];
        this.forEach(function(el){
          if (arrayUniqueAtt.indexOf(fun(el)) === -1) {
            arrayUniqueAtt.push(fun(el));
            arrayUnique.push(el);
    ...
    
  8. unique(k)
    Array.prototype.unique = function(k) {
        var self = this;
        var result = [];
        var sublen = 0;
        for (var i = 0, l = self.length; i < l; i++) {
            var v = self[i];
            if (!k) {
                if (result.indexOf(v) === -1) {
                    result.push(v);
    ...
    
  9. unique(mutate)
    Array.prototype.unique = function (mutate) {
      var unique = this.reduce(function (accum, current) {
        if (accum.indexOf(current) < 0) {
          accum.push(current);
        return accum;
      }, []);
      if (mutate) {
        this.length = 0;
    ...