Lesson content
Read, practise, then check your understanding
Use modules, small functions, clear ownership, const by default, strict equality, explicit validation, and semantic DOM APIs. Avoid hidden globals, prototype modification, implicit coercion at boundaries, swallowed rejections, unsanitized HTML, and unbounded work.
Measure real behavior
export function average(values) {
if (values.length === 0) return 0;
return values.reduce((sum, value) => sum + value, 0) / values.length;
}
Profile before optimizing. Improve algorithms and network/database behavior first; then reduce allocation, layout thrashing, bundle size, and main-thread blocking. Debounce bursty input, virtualize large views, cache with invalidation rules, and code-split expensive features. Automate formatting, static analysis, security scanning, and build checks even when repository test cases are intentionally absent.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.