Modern JavaScript Patterns

Modern JavaScript Patterns

Teaches modern ES6+ JavaScript patterns such as async/await, destructuring, modules, generators and functional programming, for refactoring legacy code and writing cleaner code.

Skill files3 files

references/

SKILL.md44 lines
1
---
2
name: modern-javascript-patterns
3
description: Master ES6+ features including async/await, destructuring, spread operators, arrow functions, promises, modules, iterators, generators, and functional programming patterns for writing clean, efficient JavaScript code. Use when refactoring legacy code, implementing modern patterns, or optimizing JavaScript applications.
4
---
5
6
# Modern JavaScript Patterns
7
8
Comprehensive guide for mastering modern JavaScript (ES6+) features, functional programming patterns, and best practices for writing clean, maintainable, and performant code.
9
10
## When to Use This Skill
11
12
- Refactoring legacy JavaScript to modern syntax
13
- Implementing functional programming patterns
14
- Optimizing JavaScript performance
15
- Writing maintainable and readable code
16
- Working with asynchronous operations
17
- Building modern web applications
18
- Migrating from callbacks to Promises/async-await
19
- Implementing data transformation pipelines
20
21
## Detailed patterns and worked examples
22
23
Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.
24
25
## Best Practices
26
27
1. **Use const by default**: Only use let when reassignment is needed
28
2. **Prefer arrow functions**: Especially for callbacks
29
3. **Use template literals**: Instead of string concatenation
30
4. **Destructure objects and arrays**: For cleaner code
31
5. **Use async/await**: Instead of Promise chains
32
6. **Avoid mutating data**: Use spread operator and array methods
33
7. **Use optional chaining**: Prevent "Cannot read property of undefined"
34
8. **Use nullish coalescing**: For default values
35
9. **Prefer array methods**: Over traditional loops
36
10. **Use modules**: For better code organization
37
11. **Write pure functions**: Easier to test and reason about
38
12. **Use meaningful variable names**: Self-documenting code
39
13. **Keep functions small**: Single responsibility principle
40
14. **Handle errors properly**: Use try/catch with async/await
41
15. **Use strict mode**: `'use strict'` for better error catching
42
43
For common pitfalls (this binding, promise anti-patterns, memory leaks), see [references/advanced-patterns.md](references/advanced-patterns.md).
44

© Seth Hobson · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…