Nodejs Array Get Unique getUnique()

Here you can find the source of getUnique()

Method Source Code

Array.prototype.getUnique = function(){
   var u = {}, a = [];
   for(var i = 0, l = this.length; i < l; ++i){
      if(u.hasOwnProperty(this[i])) {
         continue;//from ww  w . ja va  2 s.  c  om
      }
      a.push(this[i]);
      u[this[i]] = 1;
   }
   return a;
}

Related

  1. getUnique()
    Array.prototype.getUnique = function(){
       var u = {}, a = [];
       for(var i = 0, l = this.length; i < l; ++i){
          if(u.hasOwnProperty(this[i])) {
             continue;
          a.push(this[i]);
          u[this[i]] = 1;
       return a;
    
  2. getUnique()
    Array.prototype.getUnique = function(){
       var u = {}, a = [];
       for(var i = 0, l = this.length; i < l; ++i){
          if(u.hasOwnProperty(this[i])) {
             continue;
          a.push(this[i]);
          u[this[i]] = 1;
       return a;
    
  3. getUnique()
    Array.prototype.getUnique = function () {
        var u = {}, a = [];
        for (var i = 0, l = this.length; i < l; ++i) {
            if (u.hasOwnProperty(this[i])) {
                continue;
            a.push(this[i]);
            u[this[i]] = 1;
        return a;
    var a = [1, 0, 0, 2, 3, 2, 4, 6, 2, 4, 6];
    console.log(a.getUnique());
    
  4. getUnique()
    Array.prototype.getUnique = function(){
        var o = {}, a = [], i, e;
        for(i = 0; e = this[i]; i++){o[e] = 1};
        for(e in o) {a.push (e)};
        return a;