Skip to content

Instantly share code, notes, and snippets.

@knownothingsnow
Created May 28, 2016 19:54
Show Gist options
  • Save knownothingsnow/509779e8d4c4c7a2fd2422e2fdbfa29d to your computer and use it in GitHub Desktop.
Save knownothingsnow/509779e8d4c4c7a2fd2422e2fdbfa29d to your computer and use it in GitHub Desktop.
数组去重的ES5解法
function unique(arr) {
let n = []
arr.forEach((item, index) => {
if (n.indexOf(item) === -1) n.push(item)
})
return n
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment