Nodejs Array Unique uniquelize()

Here you can find the source of uniquelize()

Method Source Code

Array.prototype.uniquelize = function () {
    var tmp = {},
        ret = [];/*from  w  ww. ja  va 2  s  . c  o  m*/
    for (var i = 0, j = this.length; i < j; i++) {
        if (!tmp[this[i]]) {
            tmp[this[i]] = 1;
            ret.push(this[i]);
        }
    }
    return ret;
}

Related

  1. uniqueDates()
    Array.prototype.uniqueDates = function() {
      var u = [];
      for (k=0; k<this.length; k++) {
        var currentDate = new Date(this[k].annum);
        if (u.map(Number).indexOf(+currentDate) < 0) {
          u.push(currentDate);
      return u;
    ...
    
  2. uniqueNonEmpty()
    Array.prototype.uniqueNonEmpty = function () {
      var noempties = true;
      var hash = {};
      for (var i=0 ; i<this.length ; i++) {
        if (!this[i] || this[i]=="") {
          noempties = false;
        } else {
          hash[this[i]] = "1";
      var hashlength=0;
      for (i in hash) {hashlength++};
      return (this.length===hashlength && noempties);
    
  3. uniqueObjects(props)
    Array.prototype.uniqueObjects = function (props) {
        function compare(a, b) {
            var prop;
            if (props) {
                for (var j = 0; j < props.length; j++) {
                    prop = props[j];
                    if (a[prop] != b[prop]) {
                        return false;
            } else {
                for (prop in a) {
                    if (a[prop] != b[prop]) {
                        return false;
            return true;
        return this.filter(function (item, index, list) {
            for (var i = 0; i < index; i++) {
                if (compare(item, list[i])) {
                    return false;
            return true;
        });
    };
    
  4. uniquelize()
    Array.prototype.uniquelize = function() {
      var array = new Array();
      var length = this.length;
      for (var i = 0; i < length; i++) {
        if (!array.inArray(this[i])) {
          array.push(this[i]);
      return array;
    ...
    
  5. uniquelize()
    Array.prototype.uniquelize = function(){
         var ra = new Array();
         for(var i = 0; i < this.length; i ++){
             if(!ra.contains(this[i])){
                ra.push(this[i]);
         return ra;
    };
    ...
    
  6. uniquelizeES6()
    Array.prototype.uniquelizeES6=function(){
        return  [...new Set(this)]
    
  7. uniquer()
    var toEnter = (1,2,3,3,3,4,5,6,'this','this','that');
    Array.prototype.uniquer = function () {
        var uniqueValues = [];
        var checkUniqueValues = function (toBeChecked) {   
          for (var i = 0; i < uniqueValues.length; i++) {
            if (toBeChecked === uniqueValues[i]) {
              return true;
          return false;
        };
        for (var i = 0; i < this.length; i++) { 
          if(checkUniqueValues(this[i]) === false) { 
            uniqueValues.push(this[i]); 
        return uniqueValues;
    };
    var testArray = [1,2,3,3,3,3,3]
    var finalProduct = testArray.uniquer();
    module.exports.finalProduct = finalProduct;
    
  8. unique(arr)
    function unique(arr) {
      var result = [],
        hash = {};
      for (var i = 0, elem;
        (elem = arr[i]) != null; i++) {
        if (!hash[elem]) {
          result.push(elem);
          hash[elem] = true;
      return result;
    
  9. uniteUnique(arr1, arr2, arr3)
    function uniteUnique(arr1, arr2, arr3) {
      var resultArr = [];
      for (var i = 0; i < arguments.length; i++) {
        for (var j = 0; j < arguments[i].length; j++) {
          if (resultArr.indexOf(arguments[i][j]) === -1) {
              resultArr.push(arguments[i][j]);
      return resultArr;
    uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);