Nodejs Array Push Unique pushUnique(item,unique)

Here you can find the source of pushUnique(item,unique)

Method Source Code

// Push a new value into an array only if it is not already present in the array. If the optional unique parameter is false, it reverts to a normal push
Array.prototype.pushUnique = function(item,unique)
{
   if(unique === false) {
      this.push(item);//from w ww.  j a  v a  2  s  .  com
   } else {
      if(this.indexOf(item) == -1)
         this.push(item);
   }
};

Related

  1. pushIfUnique(entryIn)
    Array.prototype.pushIfUnique = function(entryIn){
        var arr = this;
        var unique = true;
        arr.forEach(function(entry){
            if(entryIn === entry){
                unique = false;
        });
        if(unique){
    ...
    
  2. 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;)
    ...
    
  3. pushUnique(item)
    Array.prototype.pushUnique = function(item){
        if(this.indexOf(item) === -1) this.push(item);
    
  4. pushUnique(item)
    Array.prototype.pushUnique = function (item){
        if(this.indexOf(item) === -1) {
            this.push(item);
            return true;
        return false;
    };
    
  5. 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);
    ...
    
  6. pushUnique(k, v)
    Array.prototype.pushUnique = function(k, v) {
      exist = false;
      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);
    ...
    
  7. pushUnique(obj)
    Array.prototype.pushUnique=function(obj){
      if(this.containsObject(obj)){
        return;
      this.push(obj);
    
  8. 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;
    ...
    
  9. 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;