Created
May 28, 2016 19:54
-
-
Save knownothingsnow/509779e8d4c4c7a2fd2422e2fdbfa29d to your computer and use it in GitHub Desktop.
数组去重的ES5解法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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