Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 743 Bytes

prefer-set-size.md

File metadata and controls

26 lines (18 loc) · 743 Bytes

Prefer use Set#size instead of convert it to Array first

✅ This rule is enabled in the recommended config.

🔧 This rule is automatically fixable by the --fix CLI option.

Prefer use Set#size directly instead of convert it to an array, and use .length of the array.

Fail

function isUnique(array) {
	return [...new Set(array)].length === array.length;
}

Pass

function isUnique(array) {
	return new Set(array).size === array.length;
}