JavaScript Language Fundamentals and Vendor-Neutral Certification Scope
This domain covers the ECMAScript language itself, not browser DOM or Node.js APIs. Expect short snippets where you must predict output, explain coercion, or identify why a closure or this binding behaves as it does. The certification is vendor-neutral, so answers should rely on standard language semantics rather than a specific runtime.
Types, coercion, and equality
JavaScript has seven primitive types-string, number, bigint, boolean, undefined, symbol, and null-plus objects. typeof null returns 'object', while typeof function(){} returns 'function'. Use === and Object.is deliberately: NaN === NaN is false, and +0 === -0 is true. The == operator performs coercion, so '5' == 5 is true; prefer strict equality unless coercion is intended. Falsy values are false, 0, -0, 0n, '', null, undefined, and NaN; all objects, including empty arrays, are truthy.
Scope, hoisting, and closures
var is function-scoped and hoisted with an initial value of undefined. let and const are block-scoped and hoisted but stay in the temporal dead zone until initialized. Function declarations are hoisted with their bodies. A closure keeps a reference to its lexical environment, not a snapshot of values.
Functions, this, and prototypes
For normal functions, this is set by the call site: obj.method() binds obj, while an unbound call in strict mode gives undefined. Arrow functions capture this lexically and cannot be used with new. Property lookup walks the prototype chain; Object.create(proto) and class both rely on it.
Worked example
function make() {
var out = [];
for (var i = 0; i < 3; i++) out.push(() => i);
return out;
}
make().map(f => f()); // [3, 3, 3]
var creates one i shared by all closures. After the loop i is 3, so every function returns 3. Replacing var with let gives [0, 1, 2] because each iteration gets a new binding.
Traps
Do not confuse hoisting with initialization; let access before declaration throws. Do not assume const freezes object contents. Do not treat typeof as a reliable null check. Remember that this depends on invocation, not definition.