Junior Web Developer study materials
Junior Web Developer study resources

Junior Web Developer: JavaScript Fundamentals

Junior Web Developer · Work through your exam, one topic at a time.

All guide sections

JavaScript Fundamentals

The JavaScript Fundamentals domain tests the language core: types and coercion, scope, functions and closures, this, arrays and objects, prototypes, modules, and the asynchronous model.

Types and coercion

There are seven primitives - string, number, bigint, boolean, undefined, symbol, null - plus objects. typeof null returns "object" (a legacy bug) and typeof fn returns "function". NaN is a number and is unequal to itself; use Number.isNaN. Falsy values are false, 0, -0, 0n, "", null, undefined and NaN; empty arrays and objects are truthy. Prefer ===, and Object.is for NaN and -0.

Scope, closures, this

let and const are block-scoped and sit in a temporal dead zone until initialised; var is function-scoped and hoisted as undefined. A closure keeps its lexical environment alive after the outer call returns. this is decided at call time: obj.method() binds obj, a bare call gives undefined in strict or module code, and arrow functions inherit this from the enclosing scope.

Async

Promises settle once. Microtasks (promise callbacks, queueMicrotask) drain before the next macrotask, so Promise.resolve().then(f) runs before setTimeout(f, 0). Promise.all rejects on the first failure, allSettled never rejects, race settles with the first result, and any resolves with the first fulfilment.

Worked example

for (var i = 0; i < 3; i++) setTimeout(() => console.log(i)); logs 3 3 3, because one function-scoped i is shared by all callbacks. Changing var to let creates a fresh binding per iteration and logs 0 1 2.

Traps

Assuming == is harmless, mutating inside map, forgetting that sort, splice and reverse mutate in place, and treating async functions as synchronous.