Skip to content
Languagesintermediate · 60 min

JavaScript & TypeScript

The language of the web. Master closures, prototypes and `this`, the event loop and async/await, and how TypeScript's static types catch bugs before runtime.

Closures, scope & this

A closure is a function plus the variables it captured from its defining scope — the basis of data privacy and callbacks. `let`/`const` are block-scoped (vs `var`'s function scope). `this` is determined by how a function is called; arrow functions capture `this` lexically, avoiding the classic callback binding bug.

The event loop & async

JS is single-threaded with an event loop. Synchronous code runs to completion; then microtasks (Promises) drain before the next macrotask (timers, I/O). async/await is syntactic sugar over Promises — `await` pauses the async function without blocking the thread.

Why TypeScript

TypeScript adds a static type system that's erased at compile time. Interfaces, generics, union/narrowing, and utility types catch whole classes of bugs (undefined access, wrong shapes) in the editor, and serve as living documentation.

Resources

Practice & test yourself

Take the quiz →