Skip to content

Instantly share code, notes, and snippets.

@Nataila
Created December 5, 2013 06:36
Show Gist options
  • Save Nataila/7801087 to your computer and use it in GitHub Desktop.
Save Nataila/7801087 to your computer and use it in GitHub Desktop.
function unique(arr) {
var ret = [];
var hash = {};
for (var i = 0; i < arr.length; i++) {
var item = arr[i];
var key = typeof(item) + item
if (hash[key] !== 1) {
ret.push(item);
hash[key] = 1;
};
};
return ret
};
c = [1,2,3,3,4,4]
a = unique(c)
alert(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment