Nodejs Utililty Methods Array Unique

List of utility methods to do Array Unique

Description

The list of methods to do Array Unique are organized into topic(s).

Method

unique()
'use strict';
Array.prototype.unique = function() {
  var newArray = [];
  for (var i = 0, l = this.length; i < l; i++) {
    if (newArray.indexOf(this[i]) === -1 && this[i] !== '') {
      newArray.push(this[i]);
  return newArray;
...
unique()
Array.prototype.unique = function() {
  var a = [];
  var l = this.length;
  for ( var i = 0; i < l; i++) {
    for ( var j = i + 1; j < l; j++) {
      if (this[i] === this[j])
        j = ++i;
    a.push(this[i]);
...
unique()
var fs = require('fs');
Array.prototype.unique = function() {
  var res = [],
    hash = {};
  for (var i = 0, elem;
    (elem = this[i]) != null; i++) {
    if (!hash[elem]) {
      res.push(elem);
      hash[elem] = true;
...
unique()
Array.prototype.unique = function() {
  var seen = {}
  return this.filter(function(x) {
    if (seen[x])
      return
    seen[x] = true
    return x
  })
unique()
Array.prototype.unique = function() {
  var array = [];
  var l = this.length;
  for(var i=0; i<l; i++) {
    for(var j=i+1; j<l; j++) {
      if (this[i] === this[j]) j = ++i;
    array.push(this[i]);
  return(array);
};
unique()
Array.prototype.unique = function () {
  var r = new Array();
  o:for(var i = 0, n = this.length; i < n; i++)
    for(var x = 0, y = r.length; x < y; x++)
      if(r[x]==this[i])
        continue o;
...
unique()
Array.prototype.unique = function() {
    return this.reduce(function(p, c) { 
                    if (p.indexOf(c) < 0) p.push(c);
                    return p;
                }, []);
unique()
function stringToBoolean(string) {
  switch(string.toLowerCase()) {
    case "true": case "yes": case "1": return true;
    case "false": case "no": case "0": case null: return false;
    default: return string;
Array.prototype.unique = function() {
    var o = {},
...
unique()
Array.prototype.unique = function() {
  var a=[];
  for (var b = 0; b < this.length; b++) {
    if(a.indexOf(this[b]) == -1) {
      a.push(this[b])
  return a
unique()
Array.prototype.unique = function() {
  var arr = [];
  for (var i = 0; i < this.length; i++) {
    if (!arr.contains(this[i])) {
      arr.push(this[i]);
  return arr;
function lowestUnique(str) {
  var arr = str.split(" ");
  var length = arr.length;
  var mapObj = {};
  var uniqueArr = arr.unique();
  for (var i = 0; i < length; i++) {
    mapObj[arr[i]] = 1 + (mapObj[arr[i]] || 0);
  var lowestNum = 100000000000;
  for (var n = 0; n < uniqueArr.length; n++) {
    if (mapObj[uniqueArr[n]] == 1) {
      if (lowestNum > uniqueArr[n]) {
        lowestNum = uniqueArr[n];
  if (lowestNum === 100000000000) {
    console.log(0);
  } else {
    arr.filter(function(e, ind, array) {
      if (e == lowestNum) {
        console.log(ind + 1);
    });