Rule proposal: `prefer-array-some`
See original GitHub issueFail
if (array.find(element => element === 'š¦')) {
}
const foo = array.find(element => element === 'š¦') ? bar : baz;
Pass
if (array.some(element => element === 'š¦')) {
}
const foo = array.some(element => element === 'š¦') ? bar : baz;
Just experienced one few days ago, and kind of follow up for https://github.com/sindresorhus/eslint-plugin-unicorn/issues/730
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:13 (1 by maintainers)
Top Results From Across the Web
SEC Proposed Rules
SEC Proposed Rules Ā· Regulation NMS: Minimum Pricing Increments, Access Fees, and Transparency of Better Priced Orders Ā· File No: S7-30-22 Ā· Comments...
Read more >sindresorhus/eslint-plugin-unicorn (Raised $2856.00)
Rule proposal : Expiring TODO comments. Rewarded#238created bysindresorhus. 1 pull request. $100.00. Rule proposal: No default parameter options.
Read more >The Most Curious Rule Proposal in Securities and Exchange ...
I write this post in response to the release (the āProposing Releaseā) regarding proposed rules (the āProposed Rulesā) under the InvestmentĀ ...
Read more >SEC's Proposed Preferential Treatment Rule: Does the Side ...
By Jennifer Kalmanides. On February 9, 2022, the Securities and Exchange Commission (the āSECā) unveiled a slate of newly proposed rules,Ā ...
Read more >The SEC's Proposed āPreferential Treatment Ruleā
On February 9, 2022, the SEC proposed a litany of new rules relating to private fund advisers (the āPrivate Fund Adviser Proposalā) that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Maybe Iāve expressed myself badly but the āhardā part is remembering to return a truthy value in the callback.
One distinct advantage
for-of
has over array methods is that it works on all iterables (NodeList, Set, Map), so itās a win-win to use it over array methods.My issue with
array#some
andarray#every
is that I think itās hard to read/understand. I preferfor-of
with abreak
statement because I donāt have to think about whether the iterator needs to returntrue
orfalse
to break the loop.