JS Guide
HomeQuestionsTopicsCompaniesResources
BookmarksSearch

Built for developers preparing for JavaScript, React & TypeScript interviews.

ResourcesQuestionsSupport
HomeQuestionsSearchProgress
HomeQuestionsjavascript

javascript

Core JavaScript concepts, ES6+, and language fundamentals

Explore 29 javascript topics to deepen your understanding

Your Progress

0 of 17 completed

0%

17 Questions

mid Level
1
What is a closure in JavaScript and why are they useful?
mid
closures
A closure is a function that has access to variables from its outer (enclosing) scope, even after the outer function has returned. They're useful for data privacy, state management, and creating function factories.
2
What are Promises in JavaScript and how do they work?
mid
async
A Promise is an object representing the eventual completion or failure of an asynchronous operation. It has three states: pending, fulfilled, or rejected, and provides .then(), .catch(), and .finally() methods for handling results.
3
How do async/await work and how do they relate to Promises?
mid
async
async/await is syntactic sugar over Promises. An async function always returns a Promise, and await pauses execution until a Promise resolves, making asynchronous code look and behave more like synchronous code.
4
Explain the JavaScript Event Loop and how it handles asynchronous operations.
mid
runtime
The Event Loop is JavaScript's mechanism for handling asynchronous operations. It continuously checks the call stack and task queues, executing callbacks from the microtask queue (Promises) before the macrotask queue (setTimeout, events).
5
How does the 'this' keyword work in JavaScript?
mid
this
The value of 'this' depends on how a function is called: in a method, it refers to the object; in a regular function, it's the global object (or undefined in strict mode); in arrow functions, it's lexically inherited from the enclosing scope.
6
What is the difference between shallow copy and deep copy in JavaScript, and how do you create each?
mid
objects
A shallow copy duplicates only top-level properties while nested objects share references; a deep copy recursively duplicates all nested objects creating fully independent copies.
7
What is the difference between microtasks and macrotasks in JavaScript?
mid
runtime
Microtasks (Promises, queueMicrotask, MutationObserver) run immediately after the current script and before any macrotasks. Macrotasks (setTimeout, setInterval, I/O) run one per event loop iteration. The microtask queue is fully drained before the next macrotask executes.
8
What are Promise.all, Promise.race, Promise.allSettled, and Promise.any, and when do you use each?
mid
async
Promise.all resolves when all promises succeed (fails fast on first rejection). Promise.race resolves/rejects with the first settled promise. Promise.allSettled waits for all to settle regardless of outcome. Promise.any resolves with the first fulfilled promise (ignores rejections unless all fail).
9
How do debounce and throttle work, and when would you use each?
mid
debounce-throttle
Debounce delays execution until a pause in activity (e.g., wait 300ms after the user stops typing). Throttle limits execution to at most once per time interval (e.g., at most once every 200ms during scrolling). Both are used to control how often expensive functions run.
10
What is currying and partial application in JavaScript?
mid
currying
Currying transforms a function that takes multiple arguments into a sequence of functions each taking one argument: f(a, b, c) becomes f(a)(b)(c). Partial application fixes some arguments of a function and returns a new function for the remaining ones.
11
What is the difference between ES Modules (ESM) and CommonJS (CJS)?
mid
modules
ES Modules use import/export syntax with static analysis and are asynchronously loaded. CommonJS uses require/module.exports with synchronous loading. ESM is the modern standard for browsers and modern Node.js, while CJS is the legacy Node.js module system.
12
When should you use Map and Set instead of plain objects and arrays?
mid
data-structures
Use Map when you need non-string keys, frequent additions/deletions, or need to preserve insertion order with a size property. Use Set when you need unique values, fast lookups with has(), or need to remove duplicates from an array.
13
What are call, apply, and bind and how do they differ?
mid
this
call, apply, and bind are Function.prototype methods that explicitly set the `this` context. call and apply invoke the function immediately (call takes individual arguments, apply takes an array), while bind returns a new function with `this` permanently bound.
14
What is the difference between block scope and function scope?
mid
scope
Function scope (var) means a variable is accessible throughout the entire function it's declared in. Block scope (let/const) limits a variable to the nearest enclosing block (if, for, while, or bare {}). Block scoping prevents common bugs like loop variable leaking and accidental overwrites.
15
What are WeakMap and WeakSet, and how do they differ from Map and Set?
mid
weakrefs
WeakMap and WeakSet hold weak references to object keys/values, allowing garbage collection when no other references exist. Unlike Map and Set, they are not iterable and have no size property.
16
Explain event bubbling, capturing, and how stopPropagation works.
mid
events
Events propagate through the DOM in three phases: capturing (top-down), target, and bubbling (bottom-up). stopPropagation() prevents the event from continuing to the next phase, while stopImmediatePropagation() also blocks remaining handlers on the current element.
17
How do you implement data polling in JavaScript?
mid
async
Data polling repeatedly fetches data at fixed intervals using setInterval or recursive setTimeout. Recursive setTimeout is preferred because it waits for the previous request to complete before scheduling the next one, preventing request pile-up on slow networks.