💼 This rule is enabled in the ✅ recommended
config.
🔧💡 This rule is automatically fixable by the --fix
CLI option and manually fixable by editor suggestions.
Set#has()
is faster than Array#includes()
.
const array = [1, 2, 3];
const hasValue = value => array.includes(value);
const set = new Set([1, 2, 3]);
const hasValue = value => set.has(value);
// This array is not only checking existence.
const array = [1, 2];
const hasValue = value => array.includes(value);
array.push(3);
// This array is only checked once.
const array = [1, 2, 3];
const hasOne = array.includes(1);