Skip to content

Instantly share code, notes, and snippets.

@tofusoup429
Created March 19, 2021 03:38
Show Gist options
  • Save tofusoup429/7e8473623db3a5d983cb294e053db0eb to your computer and use it in GitHub Desktop.
Save tofusoup429/7e8473623db3a5d983cb294e053db0eb to your computer and use it in GitHub Desktop.
export const checkIfNoSameElementExistInArray = <T extends any>(_array:T[]):boolean => {
//return false if any overlapped value exist.
//return true if no same element exists.
let arrayLen:number = _array.length;
let set = new Set(_array);
let setLen = set.size;
return arrayLen === setLen
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment