> javascript-language
Modern JavaScript (ES2022+) patterns for clean, maintainable code. Use when working with modern JavaScript features like optional chaining, nullish coalescing, or ESM. (triggers: **/*.js, **/*.mjs, **/*.cjs, const, let, arrow, async, await, promise, destructuring, spread, class)
curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/javascript-language?format=md"JavaScript Language Patterns
Priority: P0 (CRITICAL)
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 + Error Handling
async function getUser(id) {
const res = await fetch(`/api/${id}`);
return res.json(); // Errors propagate
}
// Private Fields
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
> related_skills --same-repo
> typescript-tooling
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling. (triggers: tsconfig.json, .eslintrc.*, jest.config.*, package.json, eslint, prettier, jest, vitest, build, compile, lint)
> typescript-security
Secure coding practices for TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration. (triggers: **/*.ts, **/*.tsx, validate, sanitize, xss, injection, auth, password, secret, token)
> typescript-language
Modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings. (triggers: **/*.ts, **/*.tsx, tsconfig.json, type, interface, generic, enum, union, intersection, readonly, const, namespace)
> typescript-best-practices
Idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)