modern-javascript-patterns

Implements ES6+ features, async patterns, and functional programming techniques in JavaScript code.

Updated May 23, 2026
One-click install
npx skills add https://github.com/Oatse/CWE-Automation --skill modern-javascript-patterns-oatse
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: modern-javascript-patterns
Source: https://github.com/Oatse/CWE-Automation/tree/main/.agents/skills/modern-javascript-patterns
Command: npx skills add https://github.com/Oatse/CWE-Automation --skill modern-javascript-patterns-oatse

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Legacy JavaScript codebases often rely on outdated syntax, callback pyramids, and mutable patterns that are hard to maintain and debug. This Skill provides structured guidance for refactoring to modern ES6+ syntax and applying functional programming patterns. ## Core Features & Use Cases - ES6+ Syntax Modernization: Apply arrow functions, destructuring, spread/rest operators, template literals, and enhanced object literals. - Asynchronous Patterns: Migrate callbacks to Promises and async/await, use Promise combinators, and implement retry and timeout logic. - Functional Programming: Use map/filter/reduce pipelines, currying, memoization, function composition, and immutable data updates. - Use Case: When refactoring a legacy module with nested callbacks, convert it to async/await with proper try/catch error handling and parallelize independent requests using Promise.all. ## Quick Start Refactor this 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 refactor callbacks to async/await in JavaScript?

Wrap callback-based operations in Promises, then consume them with async/await inside try/catch blocks for error handling. For independent operations, run them in parallel with Promise.all instead of awaiting sequentially.

How to update JavaScript objects immutably?

Use the spread operator to create new objects with updated properties, such as { ...user, age: 31 }. For arrays, use map, filter, and spread instead of push or splice to avoid mutating the original data.

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

Promise.all rejects as soon as any promise fails, while Promise.allSettled waits for all promises and returns each result with a fulfilled or rejected status. Use allSettled when partial results are acceptable.

Does optional chaining work with nullish coalescing?

Yes, they combine well: user?.address?.city ?? 'unknown' safely accesses nested properties and provides a default only for null or undefined. Unlike ||, the ?? operator preserves falsy values like 0 and empty strings.

When should I avoid arrow functions in JavaScript?

Avoid arrow functions when you need dynamic this binding, such as object methods that reference the instance, prototype methods, or event handlers relying on the target element. Arrow functions inherit this lexically from the enclosing scope.