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()
Array.prototype.unique = function() {
  var o = {}, i, l = this.length, r = [];
  for(i=0; i<l;i+=1) o[this[i]] = this[i];
  for(i in o) r.push(o[i]);
  return r;
};
unique()
Array.prototype.unique = function () {
  var o = new Object();
  var i, e;
  for (i = 0; e = this[i]; i++) {
    o[e] = 1
  };
  var a = new Array();
  for (e in o) {
    a.push (e)
...
unique()
Array.prototype.unique = function(){
  'use strict';
  this.sort();
  var ret = [this[0]];
  for(var index=0; index < this.length; index++){
    if(this[index] != ret[ret.length - 1]){
      ret.push(this[index]);
  return ret;
};
unique()
Array.prototype.unique = function()
    var n = {},r=[];
    for(var i = 0; i < this.length; i++)
        if (!n[this[i]])
            n[this[i]] = true;
            r.push(this[i]);
...
unique()
Array.prototype.unique = function() {
    var a = this.concat();
    for(var i=0; i<a.length; ++i) {
        for(var j=i+1; j<a.length; ++j) {
            if(a[i] === a[j])
                a.splice(j, 1);
    return a;
...
unique()
Array.prototype.unique = function() {
    var a = this.concat();
    for(var i=0; i<a.length; ++i) {
        for(var j=i+1; j<a.length; ++j) {
            if(a[i] === a[j])
                a.splice(j--, 1);
    return a;
...
unique()
Array.prototype.unique = function() {
  var json = {};
  var res = [];
  for(var i = 0;i < this.length;i++) {
    if(!json[this[i]]) {
      res.push(this[i]);
      json[this[i]] = 1;
  return res;
var a = [1,2,3,3,2,1,4,4,0,7];
console.log(a.unique());
unique()
Array.prototype.unique = function(){
    var u = {}, a = [];
    for(var i = 0, l = this.length; i < l; ++i){
        if(u.hasOwnProperty(this[i])) {
            continue;
        a.push(this[i]);
        u[this[i]] = 1;
    return a;
unique()
Array.prototype.unique = function () {
    var exist = {},
        i;
    for (i = 0; i < this.length; i++) {
        if (exist[this[i]]) {
            this.splice(i, 1);
            i -= 1;
        } else {
            exist[this[i]] = true;
...
unique()
Array.prototype.unique = function(){
   var u = {}, a = [];
   for(var i = 0, l = this.length; i < l; ++i){
      if(u.hasOwnProperty(this[i])) {
         continue;
      a.push(this[i]);
      u[this[i]] = 1;
   return a;