Last active
October 20, 2015 12:58
-
-
Save aarjithn/4cf420709f84542968c2 to your computer and use it in GitHub Desktop.
Check if there are duplicate (primitive) values in array
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 checkIfUnique(array) { | |
var map = {}; | |
for(var i = 0, size = array.length; i < size; i++) { | |
if (map[array[i]]) { | |
return false; | |
} | |
map[array[i]] = true; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment