modern-javascript-patterns
Modern JavaScript Patterns
๋ํ ๋ค์์์ ์ฌ์ฉํ ์ ์์ต๋๋ค: wshobson
Write cleaner, more maintainable JavaScript using ES6+ features like async/await, destructuring, spread operators, and functional programming patterns.
์คํฌ ZIP ๋ค์ด๋ก๋
Claude์์ ์ ๋ก๋
์ค์ โ ๊ธฐ๋ฅ โ ์คํฌ โ ์คํฌ ์ ๋ก๋๋ก ์ด๋
ํ ๊ธ์ ์ผ๊ณ ์ฌ์ฉ ์์
ํ ์คํธํด ๋ณด๊ธฐ
"modern-javascript-patterns" ์ฌ์ฉ ์ค์ ๋๋ค. Convert this callback to async/await: function getData(id, callback) { fetch('/api/' + id) .then(res => res.json()) .then(data => callback(null, data)) .catch(err => callback(err)); }
์์ ๊ฒฐ๊ณผ:
Refactored async/await version:
async function getData(id) {
try {
const res = await fetch(`/api/${id}`);
const data = await res.json();
return data;
} catch (err) {
throw err;
}
}
Benefits:
- Cleaner, synchronous-looking code
- Better error handling with try/catch
- Easier to debug and maintain
"modern-javascript-patterns" ์ฌ์ฉ ์ค์ ๋๋ค. Apply destructuring to this code: const user = { name: 'John', age: 30, address: { city: 'NYC' } }; const name = user.name; const city = user.address.city;
์์ ๊ฒฐ๊ณผ:
Refactored with destructuring:
const user = { name: 'John', age: 30, address: { city: 'NYC' } };
const { name, address: { city } } = user;
Or with renaming:
const { name: userName, address: { city: userCity } } = user;
๋ณด์ ๊ฐ์ฌ
์์ All 89 static findings are FALSE POSITIVES. The scanner misinterprets JavaScript code examples in markdown documentation as security risks. Backticks in code blocks are not shell commands. References to fetch() and dynamic import() are legitimate ES6+ patterns being taught. This is a safe educational skill about modern JavaScript patterns.
๋์ ์ํ ๋ฌธ์ (1)
์ค๊ฐ ์ํ ๋ฌธ์ (2)
๋ฎ์ ์ํ ๋ฌธ์ (2)
ํ์ง ์ ์
๋ง๋ค ์ ์๋ ๊ฒ
Legacy Code Modernization
Refactor older callback-based JavaScript code to use Promises and async/await for better readability and error handling.
Learning Modern JavaScript
Understand and apply ES6+ features like destructuring, spread operators, and modules to write more expressive code.
Code Review Improvements
Apply modern JavaScript patterns during code reviews to suggest cleaner, more maintainable implementations.
์ด ํ๋กฌํํธ๋ฅผ ์ฌ์ฉํด ๋ณด์ธ์
Convert this callback-based JavaScript function to use async/await syntax. Show the before and after code. [Insert callback code here]
Refactor this JavaScript code to use object and array destructuring. Make the code more concise and readable. [Insert code with nested properties or arrays here]
Transform this imperative JavaScript code to use functional programming with map, filter, and reduce. Show a chainable pipeline approach. [Insert loop-based transformation code here]
Show me how to implement lazy loading with dynamic import() for this feature module. Include error handling and conditional loading logic.
๋ชจ๋ฒ ์ฌ๋ก
- Use const by default, let only when reassignment is needed
- Prefer arrow functions for callbacks to avoid this binding issues
- Use async/await over Promise chains for better readability
ํผํ๊ธฐ
- Using var instead of const/let - lacks block scoping
- Callback hell with nested anonymous functions
- Mutating objects directly instead of using immutable patterns
์์ฃผ ๋ฌป๋ ์ง๋ฌธ
What is the difference between let and const?
When should I use async/await over Promises?
What is destructuring in JavaScript?
What are the benefits of arrow functions?
What is the spread operator used for?
How do dynamic imports help performance?
๊ฐ๋ฐ์ ์ธ๋ถ ์ ๋ณด
์์ฑ์
sickn33๋ผ์ด์ ์ค
MIT
๋ฆฌํฌ์งํ ๋ฆฌ
https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/modern-javascript-patterns์ฐธ์กฐ
main
ํ์ผ ๊ตฌ์กฐ