Nodejs Array Unique Check isUnique()

Here you can find the source of isUnique()

Method Source Code

"use strict";// w  ww  . jav a  2s  .c  o  m
  
Array.prototype.isUnique = function(){
    var that = this;
    var result = true;
    for (var i = 0; i < that.length; i++){
        for (var j = i+1; j < that.length; j++){
            if(that[i] === that[j]){
                result = false;
            }
        }
    }
    return result;
};

Related

  1. isUnique(obj)
    function rand(min, max){
        min = min || 0;
        max = max || 1;
        return Math.random() * (max - min) + min;
    };
    exports.randInt = function(min, max){
        return Math.floor( rand( min, max ) );
    };
    Array.prototype.isUnique = function(obj){
    ...
    
  2. isUnique(value)
    Array.prototype.isUnique = function(value){
      var idx = this.indexOf(value);
      return this.indexOf(value, idx + 1) == -1;
    };