Nodejs Array Push Unique pushUnique(k, v)

Here you can find the source of pushUnique(k, v)

Method Source Code

Array.prototype.pushUnique = function(k, v) {
   exist = false;/*from ww w.  j  a  v  a  2  s  .c  om*/
   for(var i = 0; i < this.length; i++) {
      if (this[i][k] == v) return this[i];
   }
   
   if (!exist) {
      obj = {};
      obj[k] = v;
      this.push(obj);
      return this[i++];
   }
}

Related

  1. pushUniq(el, test)
    Array.prototype.pushUniq = function(el, test) {
        if (test == null) {
            if (this.indexOf(el) < 0) {
                this.push(el);
                return true;
            return false;
        for (var i = this.length; --i >= 0;)
    ...
    
  2. pushUnique(item)
    Array.prototype.pushUnique = function(item){
        if(this.indexOf(item) === -1) this.push(item);
    
  3. pushUnique(item)
    Array.prototype.pushUnique = function (item){
        if(this.indexOf(item) === -1) {
            this.push(item);
            return true;
        return false;
    };
    
  4. pushUnique(item)
    Array.prototype.pushUnique = function (item) {
        if (this.indexOf(item) == -1) {
            this.push(item);
            return true;
        return false;
    };
    String.prototype.repeat = function (num) {
        return new Array(num + 1).join(this);
    ...
    
  5. pushUnique(item,unique)
    Array.prototype.pushUnique = function(item,unique)
      if(unique === false) {
        this.push(item);
      } else {
        if(this.indexOf(item) == -1)
          this.push(item);
    };
    ...
    
  6. pushUnique(obj)
    Array.prototype.pushUnique=function(obj){
      if(this.containsObject(obj)){
        return;
      this.push(obj);
    
  7. pushUnique(obj, equalityFunction)
    Array.prototype.pushUnique = function (obj, equalityFunction) {
      equalityFunction  = (typeof equalityFunction === "undefined") ? function(a, b) { return a === b } : equalityFunction;
      for(var n = 0; n < this.length; n++) {
        if(equalityFunction(this[n], obj)) { 
          return false;
      this.push(obj);
      return true;
    ...
    
  8. pushUnique(value)
    Array.prototype.pushUnique = function(value) {
        if (this.include(value)) return this;
        this.push(value);
        return this;
    Array.prototype.concatUnique = function(arr) {
        for (index in arr) {
            if (typeof arr[index] != "function") this.pushUnique(arr[index]);
        return this;
    
  9. pushUniquely(e)
    Array.prototype.pushUniquely = function(e){
      for(var i=0;i<this.length;i++){
        var ae = this[i];
        if(ae instanceof Array && e instanceof Array){
          if(ae.isEqual(e)) return i;
        }else{
          if(ae==e) return i;
      return this.push(e)-1;