Here you can find the source of Unique()
//Get keys from array which are true function array_keys_true(array){ var result = []; for(element in array) if(element) result.push(array[element]);/*from w w w . j av a2s .c om*/ return result; } /*Remove value from array Example: var array = ['one', 'two', 'three']; array_remove(array, 'three'); Result: array = ['one', 'two']; */ function array_remove(arr) { var what, a = arguments, L = a.length, ax; while (L > 1 && arr.length) { what = a[--L]; while ((ax= arr.indexOf(what)) !== -1) { arr.splice(ax, 1); } } return arr; } 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; }
Array.prototype.uniquelizeES6=function(){ return [...new Set(this)]
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;
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;
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]);
Array.prototype.Unique = function(){ var unique = []; this.forEach(function(e, i, a){ if(!unique.includes(e)){ unique.push(e); }); return unique; }; ...