我希望能够遍历JS数组并确定所有元素是否唯一,或者数组是否包含重复项。
示例:
my_array1 = [1, 2, 3]
my_array2 = [1, 1, 1]
我希望能够获得以下结果:
my_array1 must be return true, because this array element is unique
and array2 must be return false, because this array element is not unique
如何编写这个方法?