Here you can find the source of unique()
Array.prototype.unique = function() { var a = [];/*from ww w . ja v a 2s. c o m*/ var l = this.length; for ( var i = 0; i < l; i++) { for ( var j = i + 1; j < l; j++) { // If this[i] is found later in the array if (this[i] === this[j]) j = ++i; } a.push(this[i]); } return a; }; Array.prototype.clean = function(deleteValue) { for ( var i = 0; i < this.length; i++) { if (this[i] == deleteValue) { this.splice(i, 1); i--; } } return this; }; String.prototype.contains = function(it) { return this.indexOf(it) != -1; }; function StringBuffer() { this.buffer = []; } StringBuffer.prototype.append = function append(string) { this.buffer.push(string); return this; }; StringBuffer.prototype.toString = function toString() { return this.buffer.join(""); };
var numbers = [4,5,4,4,4,5,4,5] function unique(arr) { var newArr = []; for (var i = 0; i < arr.length; i++) { if (newArr.indexOf(arr[i]) < 0) { newArr.push(arr[i]); return newArr; ...
Array.prototype.unique = function(){ var u = {}, a = []; for(var l = 0, i = this.length-1; i >= 0; --i){ if(u.hasOwnProperty(this[i])) { continue; a.unshift(this[i]); u[this[i]] = 1; return a; };
Array.prototype.unique = function() { var key, output, value, _ref, _results; output = {}; for (key = 0, _ref = this.length; 0 <= _ref ? key < _ref : key > _ref; 0 <= _ref ? key++ : key--) { output[this[key]] = this[key]; _results = []; for (key in output) { value = output[key]; ...
Array.prototype.unique = function () { return this.filter(function (value, index, array) { return array.indexOf(value) === index; }); };
'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; ...
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; ...
Array.prototype.unique = function() { var seen = {} return this.filter(function(x) { if (seen[x]) return seen[x] = true return x })
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); };
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; ...