If you have an array with primitive values as per below;
const arr = [1, 2, 3, 4, 45, 4, 66, 3];
Is there a more efficient way to check whether all the items are unique rather than iterating all items as below?
let newArr = [];
let isUnique = true;
arr.forEach(item =>
{
if(newArr.indexOf(item) != -1)
{
isUnique = false;
break;
}
newArray.push(item);
});