Skip to content

Instantly share code, notes, and snippets.

@lzl124631x
Last active October 25, 2022 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lzl124631x/f701124762123dded0456530b08c6d60 to your computer and use it in GitHub Desktop.
Save lzl124631x/f701124762123dded0456530b08c6d60 to your computer and use it in GitHub Desktop.
array unique (preserve order)
Array.prototype.getUnique = function() {
var o = {}, a = []
for (var i = 0; i < this.length; i++) {
if (o[this[i]]) continue;
o[this[i]] = 1;
a.push(this[i]);
}
return a
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment