Certified Associate JavaScript Programmer flashcards
Certified Associate JavaScript Programmer · Build recall with a focused review session.
32 cards. Read the term and the definition here. The deck at the top of this page is optional.
- var hoisting behavior
- A var declaration is hoisted to the top of its function and initialized to undefined, so reading it before the assignment line yields undefined rather than throwing an error.
- Temporal dead zone
- The span between entering a block and executing a let or const declaration. Accessing the binding during this span throws a ReferenceError, even though the binding is hoisted.
- const immutability limit
- const prevents reassigning the identifier only. Object and array contents can still change, so const obj = {}; obj.x = 1 is valid JavaScript.
- typeof null result
- typeof null evaluates to the string "object" because of a legacy implementation quirk. Testing for null requires an explicit value === null comparison instead.
- Falsy value list
- Exactly eight values are falsy: false, 0, -0, 0n, empty string, null, undefined, and NaN. Empty arrays and empty objects are truthy.
- Abstract equality coercion
- The == operator converts operands to a common type before comparing, so 0 == "" and null == undefined are true, while === compares type and value without conversion.
- Strict mode effects
- Enabling "use strict" makes undeclared assignment throw, sets default this to undefined in plain function calls, forbids duplicate parameters, and makes silent failures throw errors.
- this in method call
- When a function is invoked as obj.method(), this refers to obj, the object preceding the final dot, regardless of where the function was originally defined.
- Arrow function this
- Arrow functions have no own this; they capture it lexically from the surrounding scope. They also lack their own arguments object and cannot be used with new.
- Closure definition
- A closure is a function that retains access to its lexical scope after the outer function returns, capturing variable bindings rather than copies of their values.
- Prototype chain lookup
- Property access checks the object, then its [[Prototype]], and continues up the chain until found or until null terminates the search, returning undefined.
- Object.freeze versus seal
- freeze makes properties non-writable and non-configurable; seal makes them non-configurable but still writable. Both are shallow and block adding properties.
- Array map versus forEach
- map returns a new array of callback results and does not mutate the source. forEach returns undefined and is used only for side effects during iteration.
- Mutating array methods
- push, pop, shift, unshift, splice, sort, reverse, fill, and copyWithin modify the original array. concat, slice, map, and filter return new arrays instead.
- Microtask versus macrotask
- Microtasks (promise handlers, queueMicrotask) run after the current stack empties and before the next macrotask (setTimeout, I/O). The microtask queue drains fully first.
- Promise settled states
- A promise starts pending and settles once as fulfilled or rejected. Later resolve or reject calls are ignored, and handlers attached after settling still run as microtasks.
- async function return value
- An async function always returns a promise. A returned value fulfills it; a thrown error rejects it. await pauses execution and resumes in a microtask.
- await execution ordering
- Code after await runs as a microtask, so it executes before any setTimeout callback scheduled earlier, because macrotasks wait for the microtask queue to drain.
- JSON.stringify omissions
- stringify drops properties whose value is undefined, a function, or a symbol, converts NaN and Infinity to null, and throws a TypeError when the structure is circular.
- ES module strictness
- ES modules are always strict mode, have top-level this equal to undefined, hoist import declarations, and expose live read-only bindings rather than copied values.
- CommonJS wrapper arguments
- Each CommonJS module is wrapped in a function receiving exports, require, module, __filename, and __dirname, which is why those identifiers exist without declaration.
- finally block execution
- The finally block runs whether try completes, throws, or returns. A return inside finally overrides any return value or thrown error from the try block.
- typeof return strings
- typeof yields undefined, boolean, number, bigint, string, symbol, function, or object. It never returns null or array, so Array.isArray is needed for arrays.
- let block scoping
- let declares a binding scoped to the nearest enclosing block, so a loop using let creates a fresh binding per iteration that callbacks correctly capture.
- Primitive versus object types
- Seven primitive types exist: string, number, bigint, boolean, undefined, symbol, null. All other values, including arrays and functions, are objects with prototypes.
- NaN comparison rule
- NaN is not equal to any value including itself, so NaN === NaN is false. Use Number.isNaN or Object.is to detect it reliably.
- Constructor new binding
- Calling a function with new creates a fresh object, sets this to it, links its prototype to the function's prototype property, and returns the object unless another object is returned.
- bind versus call
- call and apply invoke immediately with a specified this (apply takes an argument array). bind returns a new permanently bound function without invoking it.
- Object.create(null) effect
- An object created with a null prototype has no inherited members, so methods like toString and hasOwnProperty are absent and must be called from Object.prototype explicitly.
- Promise.all rejection behavior
- Promise.all rejects as soon as any input rejects, discarding other results. Promise.allSettled always fulfills with an array of status objects for every input.
- Spread versus rest syntax
- Spread expands an iterable into elements or properties, as in f(...args). Rest collects remaining arguments or properties into an array or object in a parameter list.
- Destructuring default values
- Destructuring assigns a default only when the extracted value is undefined, not when it is null, false, or zero, so {a = 5} = {a: null} yields null.