modern-javascript-patterns

Guides refactoring JavaScript code using ES6+ syntax, async patterns, and functional programming techniques.

2|Updated Feb 15, 2026
One-click install
npx skills add https://github.com/SkinnnyJay/simpill-utils --skill modern-javascript-patterns-skinnnyjay
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: modern-javascript-patterns
Source: https://github.com/SkinnnyJay/simpill-utils/tree/main/.agents/skills/modern-javascript-patterns
Command: npx skills add https://github.com/SkinnnyJay/simpill-utils --skill modern-javascript-patterns-skinnnyjay

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Legacy JavaScript codebases often rely on outdated patterns like callback pyramids, var declarations, and manual string concatenation, making code hard to read, test, and maintain. This Skill provides a structured reference for modernizing JavaScript with ES6+ features and functional programming patterns. ## Core Features & Use Cases - ES6+ Syntax Modernization: Covers arrow functions, destructuring, spread/rest operators, template literals, enhanced object literals, and modern class features including private fields. - Asynchronous Patterns: Explains Promises, Promise combinators (all, allSettled, race, any), async/await, retry logic, timeout wrappers, and async generators. - Functional Programming: Demonstrates map/filter/reduce pipelines, currying, memoization, function composition, and immutable data operations. - Use Case: When migrating a callback-based Node.js module to async/await, use this Skill to apply correct error handling with try/catch, parallelize independent calls with Promise.all, and avoid common pitfalls like unhandled rejections. ## Quick Start Refactor the attached legacy JavaScript file to use modern ES6+ syntax with async/await and immutable data patterns.

Frequently Asked Questions about modern-javascript-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert callback functions to async/await in JavaScript?▼

Wrap callback-based functions in Promises, then use async/await with try/catch for error handling. For independent async operations, run them in parallel with Promise.all instead of awaiting sequentially to improve performance.

What is the difference between Promise.all and Promise.allSettled?▼

Promise.all rejects immediately when any promise fails, while Promise.allSettled waits for all promises to complete and returns each result with a fulfilled or rejected status. Use allSettled when you need every outcome regardless of individual failures.

When should I use nullish coalescing instead of logical OR?▼

Use the nullish coalescing operator (??) when 0, empty string, or false are valid values, since it only defaults on null or undefined. Logical OR (||) treats all falsy values as missing, which causes bugs with numeric zero or empty strings.

Why does 'this' become undefined inside setTimeout callbacks?▼

Traditional function expressions lose their 'this' binding when passed as callbacks. Use arrow functions, which capture the lexical 'this' from the enclosing scope, or explicitly bind the function with .bind(this).

How do I update nested objects immutably in JavaScript?▼

Use the spread operator to create shallow copies at each nesting level, or use structuredClone for deep cloning. Avoid JSON.parse(JSON.stringify()) for objects containing functions, Dates, or undefined values since they are lost during serialization.

What are the limitations of async/await error handling?▼

Async functions silently swallow errors if you forget await or omit try/catch, producing unhandled promise rejections. Always wrap awaited calls in try/catch blocks and avoid wrapping already-async functions in new Promise constructors.