Nodejs Array Push Unique pushIfUnique(entryIn)

Here you can find the source of pushIfUnique(entryIn)

Method Source Code

Array.prototype.pushIfUnique = function(entryIn){
    var arr = this;
    var unique = true;
    arr.forEach(function(entry){
        if(entryIn === entry){
            unique = false;/*from   w  w w . j  av  a 2  s  .  co  m*/
        }
    });
    if(unique){
        arr.push(entryIn);
    }
};

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);
    ...