Last active
August 13, 2021 09:51
-
-
Save web2ls/30bbece411683dc289b95f8244370e92 to your computer and use it in GitHub Desktop.
Function to check if array is unique
This file contains hidden or 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 isUnique(array) { | |
| const u = {}; | |
| let isUnique = 1; | |
| for (let i = 0, l = array.length; i < l; ++i) { | |
| if (u.hasOwnProperty(array[i])) { | |
| isUnique = 0; | |
| break; | |
| } | |
| u[array[i]] = 1; | |
| } | |
| return isUnique; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment