javascript ยท interview prep
50 questions with short answers. Click any question to expand it, or open the full guide for code examples, follow-ups, and quizzes.
Primitive types store value directly on the Stack (stack memory) and are immutable. Reference types store an address/pointer on the Stack pointing to a mutable object located in the Heap memory.
Read full explanation with code examples โHoisting is the mechanism in JavaScript where variable and function declarations are moved to the top of their containing scope during the compilation phase, before execution begins.
Read full explanation with code examples โThe Temporal Dead Zone is the period/state between block entry and the line of declaration where variables declared with let and const cannot be accessed.
Read full explanation with code examples โScope is the actual physical boundary where a variable is accessible. Lexical Environment is the internal structure containing local variables and a reference to its parent Lexical Environment.
Read full explanation with code examples โ== (Loose Equality) checks for value equality and performs implicit type coercion. === (Strict Equality) checks for both value and type without coercion.
Read full explanation with code examples โundefined means a variable has been declared but not yet assigned a value. null is an intentional assignment representing "no value" or an empty object reference.
Read full explanation with code examples โA falsy value is a value that translates to false when evaluated in a boolean context. All other values are truthy.
Read full explanation with code examples โA pure function always returns the exact same output for the same input and produces no side effects. An impure function can yield different outputs or modify external state.
Read full explanation with code examples โA shallow copy duplicates the top-level structure, keeping reference pointers to nested objects. A deep copy recursively clones every nested value and reference, decoupling them entirely.
Read full explanation with code examples โconst prevents reassignment of a variable reference. Object.freeze() makes the properties of an object read-only and prevents adding or removing properties.
Read full explanation with code examples โTemplate literals are string literals delimited with backticks (`), allowing multi-line strings, string interpolation, and tagged templates.
Read full explanation with code examples โArrow functions do not have their own this context (they inherit it lexically), do not have an arguments object, and cannot be used as constructors.
Read full explanation with code examples โThe spread operator (...) unpacks items from an array/object. The rest operator collects multiple separate arguments or items into a single array structure.
Read full explanation with code examples โDestructuring is a clean syntax that allows unpacking properties from objects or values from arrays directly into individual variables.
Read full explanation with code examples โMap allows keys of any data type (including objects/functions) and maintains insertion order, whereas Object keys must be Strings or Symbols.
Read full explanation with code examples โA closure is the combination of a function bundled together with references to its surrounding state (the lexical environment). It lets an inner function access the outer scope even after the outer function has finished executing.
Read full explanation with code examples โExecution Context is the environment in which code is evaluated and executed. The Call Stack is a LIFO (Last In, First Out) data structure used to manage execution contexts.
Read full explanation with code examples โA prototype is an object linked to every function/object in JS where properties and methods can be inherited. The Prototype Chain is the mechanism of traversal from child prototypes upward up to Object.prototype to resolve a property.
Read full explanation with code examples โthis refers to the object currently executing the function, evaluated entirely at execution runtime based on how the function was invoked.
Read full explanation with code examples โcall invokes a function immediately, specifying this and passing arguments individually. apply does the same but accepts arguments as an array. bind returns a new function with this locked, to be called later.
Read full explanation with code examples โA Promise is an object representing the eventual completion or failure of an asynchronous operation, existing in three states: Pending, Fulfilled, or Rejected.
Read full explanation with code examples โAsync/Await is syntactic sugar built on top of Promises. It allows writing asynchronous code that looks and behaves like synchronous sequential code.
Read full explanation with code examples โThe Event Loop is the runtime mechanism that continuously monitors the Call Stack and moves callbacks from the Callback and Microtask Queues to the stack when the stack is empty.
Read full explanation with code examples โEvent delegation is a design pattern where you attach a single event listener to a parent element instead of individual child nodes, leveraging event bubbling.
Read full explanation with code examples โDebouncing limits the execution of a function until a specified idle duration has elapsed since its last invocation.
Read full explanation with code examples โThrottling enforces a maximum frequency rate of execution, ensuring a function fires at most once per defined time window.
Read full explanation with code examples โCapturing (trickling) goes top-down from parent elements down to the target. Bubbling goes bottom-up, from the clicked child target up through parents to the global window root.
Read full explanation with code examples โClasses are syntactic sugar built over JavaScript's existing prototype-based inheritance model, providing cleaner OOP structure.
Read full explanation with code examples โES6 modules use import and export statements. They load statically, execute strictly, and help build decoupled tree-shakeable codebases.
Read full explanation with code examples โA Set is an unordered collection of unique values, while an Array is an ordered collection allowing duplicate values.
Read full explanation with code examples โCurrying is a pattern where a function taking multiple arguments is transformed into a series of nested functions that take only one argument each.
Read full explanation with code examples โMemoization is an optimization technique that caches the return values of expensive function computations based on their input parameters.
Read full explanation with code examples โA polyfill is fallback JS code used to provide modern feature support to older browser clients lacking that capability.
Read full explanation with code examples โPromise.all rejects immediately if any promise in the array fails. Promise.allSettled waits for all inputs to complete/fail and returns their status arrays.
Read full explanation with code examples โA callback is a function passed as an argument to another function. Callback Hell is the term for deeply nested, unreadable callback structures that complicate control flow.
Read full explanation with code examples โIterators are objects defining a standard next() output sequence structure. Generators are special functions that can pause/resume execution via the yield keyword, producing iterators under the hood.
Read full explanation with code examples โA memory leak occurs when items are no longer used by the application but remain allocated in the Heap because references to them are still active.
Read full explanation with code examples โGarbage Collection is an automated process in the JS engine that frees up memory occupied by objects that are no longer reachable from the root execution contexts.
Read full explanation with code examples โWeakMap and WeakSet are collections that only accept objects/symbols as keys, maintaining "weak" references to those objects so they can be collected by Garbage Collection if no other references exist.
Read full explanation with code examples โA Proxy wraps an object, letting you intercept and customize fundamental operations like reading, writing, and modifying properties.
Read full explanation with code examples โReflect is a built-in object providing methods to call interceptable JavaScript operations, mirroring proxy interceptors to simplify forwarding operations.
Read full explanation with code examples โWeb Workers are browser APIs allowing JavaScript code to execute in background background threads, independent of the main user-interface thread.
Read full explanation with code examples โV8 parses JavaScript into an Abstract Syntax Tree (AST), compiles it to Bytecode via the 'Ignition' interpreter, and optimizes it using 'TurboFan' into fast machine code based on hot performance loops.
Read full explanation with code examples โA custom function that returns a Promise, iterates through the array of promises, resolves each, and collects the results in a matching-index array. If any promise rejects, it rejects immediately.
Read full explanation with code examples โA custom utility function that recursively copies all elements of objects and arrays, preserving depth and references while decoupling original entities.
Read full explanation with code examples โA Class representing a custom Promise implementation that captures status, value, and callbacks, handling asynchronous execution flows manually.
Read full explanation with code examples โTail Call Optimization is a compiler mechanism where the engine avoids allocating a new stack frame if the last action of a function is a direct call returning another function.
Read full explanation with code examples โA Symbol is a unique and immutable primitive value, primarily used to create hidden, collision-free object property keys.
Read full explanation with code examples โA Shadow DOM is a self-contained, encapsulated DOM tree detached from the main document DOM, preventing styles and structures from leaking in or out.
Read full explanation with code examples โTricks usually target unexpected behaviors like 0.1 + 0.2 !== 0.3 (floating-point binary representation), NaN !== NaN, and automatic semicolon insertion side-effects.
Read full explanation with code examples โ