modern-array-methods
Installation
SKILL.md
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.