Something like this:
let a = [2, 34, 'dafsd', null, {}];
let b = [null, null] -or- ['same','same'] -or- [100, 100]
isDistinct(a) // => true
isDistinct(b) // => false
Something like this:
let a = [2, 34, 'dafsd', null, {}];
let b = [null, null] -or- ['same','same'] -or- [100, 100]
isDistinct(a) // => true
isDistinct(b) // => false
You could take a Set
of the items and check the length of the array against the size of the set. If equal, then all elements are unique.
let a = [2, 34, 'dafsd', null, {}];
console.log(a.length === new Set(a).size);