Skip to content

Instantly share code, notes, and snippets.

@swdyh
Created June 5, 2011 16:35
Show Gist options
  • Save swdyh/1009134 to your computer and use it in GitHub Desktop.
Save swdyh/1009134 to your computer and use it in GitHub Desktop.
function uniq(arr, f) {
var r = []
var h = {}
var f = f ? f : JSON.stringify
arr.forEach(function(i) {
var v = f(i)
if (!h.hasOwnProperty(v)) {
r.push(i)
}
h[v] = true
})
return r
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment