8 lab JavaScript runtime và TypeScript
Mỗi lab ghi expected semantics trước khi chạy, sau đó dùng test, profiler hoặc browser evidence để giải thích—not chỉ chụp output.
Coercion và equality matrix
Tạo matrix primitive/object conversions, ===/Object.is/SameValueZero, NaN/zeros/safe integers/decimal. Viết boundary parser explicit và property-based invariants.
Closure và module lifecycle
Tái hiện var-loop closure, TDZ, circular ESM và singleton state leak giữa tests/users. Sửa bằng per-iteration binding, dependency/lifecycle rõ; profile retained closure.
Prototype/object security
Implement descriptors/prototype/class/private fields; viết unsafe deep merge để tái hiện prototype pollution rồi chặn dangerous keys/validate records. Test cross-realm instanceof caveat.
Scheduler và cancellation
Vẽ/run task-microtask order, tạo microtask starvation, typed debounce/throttle có cancel/flush, concurrency limiter, stale request race và timeout. Sửa bằng yield, AbortSignal, request version; test fake + real timers phù hợp.
Browser API/security
Vanilla app với event delegation, fetch streaming/error/abort, storage choice. Tái hiện unsafe innerHTML/XSS trong sandbox rồi sửa textContent/sanitization/CSP; test CORS vs authz.
TypeScript state and boundary
Bật strict, noUncheckedIndexedAccess và exactOptionalPropertyTypes; model async state bằng discriminated union/exhaustive never. Parse unknown JSON bằng runtime schema; loại any/non-null assertions.
Generic library và package contract
Viết typed event bus/API client giữ relation key→payload/result; declaration/type tests, ESM exports và consumer project. Tái hiện paths/runtime mismatch và version breaking change.
Performance, tests và supply chain
Bundle app, đo chunks/duplicates/Core Web Vitals/long task/memory; optimize bằng code split/lifecycle cleanup. Thêm unit/DOM/E2E/a11y, lockfile/SCA/secret scan/SBOM và untrusted-PR review.
Rubric
| Mức | Tiêu chí |
|---|---|
| 1 | Giải thích được output và types. |
| 2 | Có runtime/browser/type failure tests. |
| 3 · Senior | Security/performance/toolchain evidence và production-safe boundary design. |