javascript-language-patterns
maintained by HoangNguyen0403
star
143
account_tree
48
verified_user
MIT License
name: JavaScript Language Patterns description: Modern JavaScript (ES2022+) patterns for clean, maintainable code. metadata: labels: [javascript, language, es6, modern-js] triggers: files: ['/*.js', '/.mjs', '**/.cjs'] keywords: [const, let, arrow, async, await, promise, destructuring, spread, class]
JavaScript Language Patterns
Priority: P0 (CRITICAL)
Modern JavaScript standards for clean, maintainable code.
Implementation Guidelines
-
Variables:
constdefault.letif needed. Novar. - Functions: Arrows for callbacks. Declarations for top-level.
-
Async:
async/await+try/catch. -
Objects: Destructuring, Spread
..., Optional Chain?., Nullish??. -
Strings: Template literals
${}. -
Arrays:
map,filter,reduce. No loops. -
Modules: ESM
import/export. Export only what is necessary. -
Classes: Use
#privatefields for true privacy.
Anti-Patterns
-
No
var: Block scope only. -
No
==: Strict===. -
No
new Object(): Use literals{}. - No Callbacks: Promisify everything.
- No Mutation: Immutability first.
Code
// Modern Syntax
const [x, ...rest] = items;
const name = user?.profile?.name ?? 'Guest';
// Async
async function getUser(id) {
try {
const res = await fetch(`/api/${id}`);
return res.json();
} catch (err) {
console.error(err);
throw err;
}
}
// Class + Private
class Service {
#key;
constructor(k) {
this.#key = k;
}
}
Reference & Examples
For advanced patterns and functional programming: See references/REFERENCE.md.
Related Topics
best-practices | tooling
chat Comments (0)
Sign in to join the discussion and leave a comment.
Skill Details
GitHub Stars
143
GitHub Forks
48
Created
Jan 2026
Last Updated
8 months ago
tools
tools architecture patterns
Related Skills
Build your own?
Join 12,000+ developers contributing to the Claude ecosystem.
No comments yet. Be the first to share your thoughts!