modern-js
Installation
SKILL.md
Modern JavaScript Preferences (ES2025/ES2026)
Model training cutoffs predate most of these APIs. When writing JavaScript, check every function you produce against this list before finalizing. Prefer the newer API unless the target runtime doesn't support it — in that case, suggest a polyfill.
Iterators and collections
Iterating a large or infinite sequence
Use Iterator.prototype methods (.map, .filter, .take, .drop, .toArray). They're lazy, so they work on infinite iterators and don't allocate intermediate arrays.
// BAD: materializes the whole sequence
const firstTenEvenSquares = [];
for (const n of naturalNumbers()) {
if (n % 2 === 0) {
firstTenEvenSquares.push(n * n);
if (firstTenEvenSquares.length === 10) break;
}
}