本文へスキップ
Skillpedia
WebサイトとUI(フロントエンド)75k · #2943

modern-array-methods

できること

このスキルは、ループが意図を隠している箇所で、新しい配列やオブジェクトのメソッドを提案しながら JavaScript のコードを見直します。より短く、追いやすいコードを作りたい開発者向けです。

使う場面

  • ✓JavaScript のループを新しい配列メソッドを使って整理してほしいとき。
  • ✓データを絞り込み、変換、検索する長い for や while のループがあるとき。
  • ✓コードを確認していて、オブジェクトの安全なコピーやデータ変換の方法を探したいとき。

スキルのリンク

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/modern-array-methods/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/modern-array-methods/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“JavaScript ファイルのループを新しい配列メソッドで書き直し、読みやすくしてもらえますか。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、map、filter、reduce、find、flatMap に置き換えられるループを見つけます。メソッド名を見るだけで、各ステップの目的が分かるように書き直します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Use modern array and object methods

Modern array and object methods produce code that directly expresses intent — a filter() call self-documents that you're selecting items. Manual for loops obscure the purpose behind implementation details. These methods are also well-optimized by JavaScript engines and support chaining for concise data transformations.

Quick Reference

  • Use map() to transform arrays, filter() to select items, reduce() for aggregation
  • Use find() and findIndex() instead of manual loops with break
  • Use Object.entries() and Object.fromEntries() to transform objects
  • Use structuredClone() for deep copying instead of JSON.parse(JSON.stringify())

Check

Find loops in this file that could be replaced with modern array methods like map, filter, reduce, find, or flatMap.

Fix

Replace manual for/while loops with appropriate array methods to make the code more declarative.

Explain

Explain map, filter, reduce, find, flatMap, and Object.entries with practical examples.

Code Review

Review scripts, client components, and browser execution paths related to Use modern array and object methods. Flag exact imports, event handlers, runtime side effects, or blocking operations that violate the rule, and state how the change should be verified in the browser.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/javascript/modern-array-methods

よくある質問

なぜループの代わりに filter を使うのですか?

filter の呼び出しは、項目を選んでいることが一目で分かりますが、手作業のループでは詳細に隠れてしまうためです。

structuredClone は何のためのものですか?

古い JSON.parse と JSON.stringify の方法の代わりに、深いコピーをするために勧められています。

この変更で動作は変わりますか?

結果は同じはずですが、このスキルはブラウザで変更を確認することを勧めています。

詳細

作者による元の説明

Use when reviewing scripts, client components, bundles, or runtime behavior related to Use modern array and object methods. Inspect both source code and the browser execution path so fixes target the real bottleneck or bug.

repo: thedaviddias/Front-End-Checklist

人気

GitHubのスター
75k
ランキング
#2943
ライセンス
MIT
更新日
2026/10/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル