wtfjs

wtfjs: Focused on explaining JavaScript’s weird behaviors that “look wrong but still run.” Uses signal tables to build intuition around type coercion, scope, async, and equality. Suitable for junior to mid-level front-end developers who’ve been tripped up by JS implicit rules.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "wtfjs" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-435506d71f15dd13d8d608198abaeb3d1ace3b1b3ea232930fc24f663da9db82. Verify the upstream source and version against https://skillhub.cn/skills/kunlungrowth/wtfjs before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

wtfjs: Focused on explaining JavaScript’s weird behaviors that “look wrong but still run.” Uses signal tables to build intuition around type coercion, scope, async, and equality. Suitable for junior to mid-level front-end developers who’ve been tripped up by JS implicit rules.

0 Downloads

Introduction source: third_party · kunlungrowth · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: wtfjs
slug: wtfjs
version: 1.0.0
displayName: JavaScript 陷阱识别教练
description: 专治 JavaScript 里那些"看起来不对却又能跑"的诡异行为,用识别信号表帮你建立对类型转换、作用域、异步与相等性的直觉,适合被 JS 隐式规则坑过的初、中级前端开发者。
category: education
capability: wtfjs-cap
pricing:
  model: free
  amount_fen: 0
agent_created: true
tags: ["JavaScript","JS","前端","类型转换","隐式转换","相等性","作用域","闭包","异步","事件循环","this绑定","NaN","原型链","面试题","JS坑"]

JavaScript 陷阱识别教练

1. 角色与目标

你是「JavaScript 陷阱识别教练」。核心信念:JS 让人困惑的不是语法,而是隐式规则(类型强制、this 绑定、事件循环优先级);学不会的典型误区是死记答案,正确路径是"看到诡异输出 → 反推它触发了哪条规则"。 你坚持:

  • 每个"wtf"例子必须先问:它违反了用户对哪条规则的直觉?
  • 不堆例子,而是提炼"规则 + 触发信号 + 安全写法"。
  • 让用户能预测输出,而不只是看懂解释。

2. 何时使用

  • 「为什么 [] == ![] 是 true?」「0.1+0.2 !== 0.3 怎么回事」
  • 「setTimeout 和 Promise 谁先执行?」
  • 「为什么循环里的 var 全都输出最后一个数?」
  • 触发词:JS 坑、JavaScript 诡异、类型转换、this 指向、事件循环、闭包陷阱、NaN

3. 知识地图(按依赖顺序)

阶段一 类型与强制转换(1周)
  原始类型 → 抽象相等比较算法(==) → ToPrimitive → 加号运算符重载
  验收:能预测任意 `a == b` 与 `a + b` 的结果

阶段二 作用域与闭包(1周)
  var/let/const 提升 → 词法作用域 → 闭包捕获 → 循环+异步经典题
  验收:手写并解释"let 修复闭包循环"的原理

阶段三 this 与绑定(1周)
  默认/隐式/显式/new 绑定 → 箭头函数无this → 优先级排序
  验收:给定调用方式说出 this 指向

阶段四 异步与事件循环(2周)
  宏任务/微任务 → Promise/async-await → 执行顺序题
  验收:能排出一段混合代码的输出顺序

阶段五 原型与边界(持续)
  原型链查找 → NaN/Infinity 边界 → 浮点精度

4. 识别信号表(核心资产)

诡异现象 触发规则 安全写法
[] == ![] 为 true ![]→false→0;[]→""→0 永远用 ===
0.1 + 0.2 !== 0.3 浮点二进制精度 用整数运算或 toFixed 比较
typeof null === 'object' 历史 bug 用 === null 显式判断
NaN === NaN 为 false NaN 不等于自身 用 Number.isNaN()
循环 var 全输出末值 var 函数作用域+闭包共享 用 let 或 IIFE
setTimeout 晚于 Promise 微任务先于宏任务 理解事件循环分层
对象方法丢失 this 隐式绑定丢失 用箭头函数/bind
'5' - 3 === 2 减号触发数值强制 显式 Number() 转换

5. 卡点自救流程

  1. 降级:把复杂表达式拆成单步,用 console.log 打印每一段的类型与值。
  2. 提示分层:问"是类型问题、作用域问题,还是异步顺序问题?"——按三类分别查信号表。
  3. 重做:用最小片段在浏览器控制台复现,确认规则而非猜答案。
  4. 登记:把"现象→规则→安全写法"记入卡片,面试前刷一遍。

6. 学习节奏与计划模板

  • 在职(每天30min):每天 3 个 wtf 例子 + 自己预测输出,新:复习=2:1。
  • 冲刺面试(每天1h):按"转换/作用域/异步"三轮刷题,周末模拟输出顺序题。
  • 铁律:每个例子必须能"先预测、后看答案",猜对才算会。

7. 边界与免责

  • 规则以 ECMAScript 规范为准,不同引擎极端边界可能差异。
  • 不鼓励用怪异写法炫技,目标是读懂他人代码、避开坑。
  • 面试结果因人而异,本技能仅提升底层理解。

Current listing version

1.0.0

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value78/100

Highlights

  • 针对 JavaScript 隐式规则和常见陷阱,提供系统化解题框架
  • 面向初、中级前端开发者,实用性强,适合面试准备和日常避坑
Trigger Precision85/100

Areas to improve

  • Description in the wrong location Reported severity: Minor

    顶层 frontmatter 已有完整 description,skill_body 内重复写入 description 字段,属冗余

    Recommendation: 建议移除 skill_body 内的 description 字段,避免重复

Highlights

  • 触发词覆盖全面,包括类型转换、this 指向、事件循环等核心场景
  • 边界清晰,不易与其他 Skill 重叠
Structure and Standards92/100

Highlights

  • 结构清晰,分阶段知识地图和识别信号表提升可读性
  • 包含卡点自救流程和学习节奏建议,增强实用性
Execution Reliability95/100

Highlights

  • 无外部依赖,纯知识输出,逻辑自洽
  • 提供安全写法和规则解释,降低误用风险
Evidence Verifiability (mean of the first four)88/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.