Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 655 Bytes

prefer-array-some.md

File metadata and controls

27 lines (20 loc) · 655 Bytes

Prefer .some(…) over .find(…).

Prefer using Array#some over Array#find when ensuring at least one element in the array passes a given check.

Fail

if (array.find(element => element === '🦄')) {
	// …
}
const foo = array.find(element => element === '🦄') ? bar : baz;

Pass

if (array.some(element => element === '🦄')) {
	// …
}
const foo = array.find(element => element === '🦄') || bar;