Skip to content

Instantly share code, notes, and snippets.

@ryan-allen
Created December 7, 2010 02:02
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 ryan-allen/731354 to your computer and use it in GitHub Desktop.
Save ryan-allen/731354 to your computer and use it in GitHub Desktop.
var unique = function(array) {
var pushed = {}, output = []
for (n in array) {
var value = array[n]
if ( !pushed[value] ) {
output.push(value)
pushed[value] = true
}
}
return output
}
unique(['stu', 'stu', 'stu', 'lol', 'fart', 'poop', 'poop']) // returns ['stu', 'lol', 'fart', 'poop']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment