Skip to content

Instantly share code, notes, and snippets.

@web2ls
Last active August 13, 2021 09:51
Show Gist options
  • Select an option

  • Save web2ls/30bbece411683dc289b95f8244370e92 to your computer and use it in GitHub Desktop.

Select an option

Save web2ls/30bbece411683dc289b95f8244370e92 to your computer and use it in GitHub Desktop.
Function to check if array is unique
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