Contains Duplicate 1 line javascript solution

Set contains only unique values.
So, if there are duplicates in the nums array, then the length/size of the set will get reduced.

var containsDuplicate = function(nums) {
    return new Set(nums).size !== nums.length;
};
Comments (1)