Skip to main content

javascript

Write modern, idiomatic JavaScript with ES2022+ features and async patterns.

来源信息

仓库
glayph/Agent
最近来源活动
2026年9月19日 22:39
检测到的 SKILL.md 语言
英语
星标
0
分支
0

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
javascript
description
Write modern, idiomatic JavaScript with ES2022+ features and async patterns.
version
1.0.0
author
Miki
license
MIT
platforms
["linux","macos","windows"]
metadata
{"Miki":{"tags":["javascript","es6","async","es2022"],"related_skills":["frontend-frameworks","testing-debugging"]}}
# JavaScript (ES6+) ## Modern syntax preferences - `const` / `let` over `var` - Arrow functions for callbacks, named functions for top-level - Template literals over string concatenation - Destructuring for object/array access - Spread `...` over `Object.assign` - Optional chaining `?.` and nullish coalescing `??` - Ternary over `if/else` for simple branching ## Array methods (chainable) ```js const result = arr .filter(Boolean) .map(item => item.value) .filter((v, i, a) => a.indexOf(v) === i) // unique .sort((a, b) => a - b) .reduce((acc, v) => acc + v, 0); ``` ## Async patterns ```js // Prefer async/await over .then() // Parallel: Promise.allSettled() over Promise.all() // Timeout: Promise.race([fetch(url), timeout(5000)]) // Sequential: for...of with await inside ``` ## Error handling ```js try { const result = await risky(); if (!result) throw new Error("not found"); } catch (err) { if (err instanceof SyntaxError) { /* recover */ } throw; // rethrow unknown } ``` ## Module conventions - Named exports over default exports - Barrel files (`index.js`) for public API surface - Absolute imports with path aliases (no `../../../`) - `import type` for type-only imports (TS) ## Performance rules - Debounce input handlers (300ms) - Throttle scroll/resize (100ms) - Avoid forced reflows — batch DOM reads/writes - Use `requestAnimationFrame` for visual updates - Memoize pure computations - `for` loops > array methods at scale (10k+ items)
在 GitHub 查看