Skip to Content
Skip to content
PROGRAMMING

JavaScript Tutorials

Targeted JavaScript tutorials for solving real browser and Node.js issues—from event delegation and fetch timeouts with AbortController to finding slow click handlers in Chrome's Performance panel and stopping memory leaks.

Every guide includes runnable code, exact console or profiler output, and clear trade-offs so you can verify the behavior before shipping it.

JavaScript
Why Your Date Is Off by One Day Level: Intermediate

Your date moves a day because one part of the code uses UTC and another uses local time.

JavaScript
Destructuring Function Parameters With Defaults Level: Intermediate

Replace long lists of positional arguments with one options object, destructured in the parameter list with defaults.

JavaScript
Fix "Cannot use import statement outside a module" Level: Intermediate

The file was loaded as a classic script or CommonJS, where import isn't allowed. The fix in the browser is type="module".

JavaScript
Install Node.js and Check It Actually Works Level: Intermediate

Install the LTS version of Node.js, check the installer's signature, and prove it works in a new terminal with node -v, npm -v and one real install.

JavaScript
Fix "Unexpected token in JSON" Errors Level: Intermediate

"Unexpected token in JSON" means JSON.parse got text that isn't JSON. Read the exact message, log the raw text, and match it to one of five causes.

JavaScript
npm install vs npm ci: Same Install on Every Machine Level: Intermediate

Use npm ci to install exactly what the lock file says and npm install to change it.

JavaScript
Your First Test With Vitest Level: Intermediate

Add Vitest to a project you already have and get real tests passing: a pure function with it.each, then an async function that calls fetch, tested with a fake instead of the network.

JavaScript
Closures for Private State: A Counter You Can't Break Level: Advanced

Keep a counter's value in a closure so nothing outside can set it to -5 or "abc". The pattern, how it compares with a class with

JavaScript
Fix a Bound Event Listener That Will Not Detach Level: Advanced

Trace a wrong callback receiver, bind one stable listener, and verify start, stop and restart without duplicate or stale subscriptions.

JavaScript
Predict the Output: Event Loop Order in 6 Snippets Level: Advanced

Six short snippets with setTimeout, promises, await and queueMicrotask. Predict the order, run it, then read why.