Skip to content
Live on Product Hunt

We just launched BrainUp on Product Hunt. Thanks for coming over!

BrainUp
  • Templates
  • Resume Guides
  • Blog
  • Pricing
  • Contact
Log inBuild Resume
  • Templates
  • Resume Guides
  • Blog
  • Pricing
  • Contact
  • Log in
Build My Resume — Free
BrainUp

Build your resume. Then build your advantage. The career productivity toolkit for your whole job search.

Products

  • Free Resume Builder
  • Cover Letter Builder
  • LinkedIn Optimizer (Premium)
  • AI Interview Prep (Premium)
  • Job Tracker (Premium)

Resources

  • Resume Templates
  • Resume Guides
  • Career Blog

Company

  • Pricing
  • Contact us

Legal

  • Terms
  • Privacy
  • Cookies

© 2026 BrainUp. All rights reserved. ·

BrainUp is a career productivity tool, not a recruitment agency. We help you prepare — we don't guarantee interviews, job offers or ATS outcomes.

BrainUp

  1. Home
  2. JavaScript Interview Questions

JavaScript interview prep

JavaScript Interview Questions: Closures to the Event Loop

JavaScript interviews test scope and closures, hoisting, how this works, prototypes, promises and async/await, the event loop, and everyday array and object methods. Many rounds also ask you to write small utilities like debounce or a deep clone.

Practise with AI Interview PrepSee frontend developer resume
  • 16 questions answered
  • Code examples
  • Async explained
  • Fresher to mid-level

Sample answers

Explain with a 3-line example.

A tiny example proves understanding faster than a definition.

Model answers for 4 JavaScript questions

Typical round: concepts, output-prediction questions, a small coding task

Q: What is a closure? A: A function that remembers variables from the scope where it was created, even after that scope has finished. For example, a counter function returned from makeCounter() keeps its own count variable between calls. Closures power data privacy, callbacks and hooks.

Q: How does the event loop work? A: JavaScript runs one call stack. Async callbacks wait in queues. When the stack is empty, the event loop runs all microtasks first, like promise callbacks, then takes the next macrotask, like a setTimeout callback. That's why a resolved promise logs before setTimeout(fn, 0).

Q: What is the difference between var, let and const? A: var is function-scoped and hoisted with undefined. let and const are block-scoped and sit in the temporal dead zone until declared. const prevents reassignment, but objects declared with const can still be mutated.

Q: What does this refer to? A: It depends on how a function is called: the object before the dot for method calls, undefined in strict-mode plain calls, the new instance with new, and whatever bind, call or apply sets. Arrow functions don't have their own this; they use the surrounding one.

What interviewers check

Built for scanners, humans and hiring intent.

  • Language fundamentals

    Scope, closures, hoisting and this are the foundation every follow-up builds on.

  • Async mastery

    Promises, async/await and the event loop are asked in nearly every JavaScript round.

  • Reading code

    Predicting output of tricky snippets tests whether you really understand the runtime.

  • Practical utilities

    Debounce, throttle, deep clone and array polyfills show you can write real code.

Examples

Copy the structure, not the wording.

These examples show shape and specificity. Add your own facts, metrics, tools and outcomes.

Core concepts

  • == vs ===?
  • What is hoisting?
  • What are primitive vs reference types?
  • What is a prototype?
  • What is the spread operator?

Output prediction

  • What does console.log(typeof null) print?
  • Order of logs: setTimeout vs Promise.then?
  • What happens with var in a for loop with setTimeout?
  • What is [] + {} ?
  • What does 0.1 + 0.2 === 0.3 return?

Coding tasks

  • Write a debounce function.
  • Implement Array.prototype.map.
  • Flatten a nested array.
  • Deep clone an object.
  • Implement Promise.all.

Actionable tips

Small edits that lift response rates.

Run through these before every application.

  1. 1Think out loud on output questionsWalk through scope and the event loop step by step instead of guessing.
  2. 2Know modern syntaxDestructuring, optional chaining, modules and async/await should feel natural.
  3. 3Practise five utilitiesDebounce, throttle, deep clone, flatten and Promise.all come up often.
  4. 4Mention TypeScriptMany teams use it. Saying how you type functions and objects is a plus.
  5. 5Rehearse explanationsBrainUp AI Interview Prep runs JavaScript mock interviews and flags unclear answers.

FAQ

Common questions, direct answers.

What is the difference between == and ===?

== compares after type coercion, so '1' == 1 is true. === compares value and type without coercion, so '1' === 1 is false. Prefer ===.

What is hoisting in JavaScript?

Declarations are moved to the top of their scope during compilation. var declarations are initialised as undefined, functions are fully hoisted, and let and const are hoisted but not initialised.

What is a closure?

A function bundled with references to its surrounding scope, letting it access outer variables even after the outer function has returned.

What is the event loop?

The mechanism that runs queued callbacks when the call stack is empty, processing all microtasks like promise callbacks before the next macrotask like a timer.

What is the difference between var, let and const?

var is function-scoped and can be redeclared. let and const are block-scoped; const can't be reassigned, though object contents can change.

What is a promise?

An object representing a future value that is pending, fulfilled or rejected. You handle it with then and catch, or with await inside an async function.

What is async/await?

Syntax for writing promise-based code that reads like synchronous code. await pauses the async function until the promise settles; errors are caught with try/catch.

How does this work in JavaScript?

this is set by how a function is called: the calling object, the new instance, a bound value, or undefined in strict mode. Arrow functions inherit this from their enclosing scope.

What is prototypal inheritance?

Objects link to a prototype object and inherit its properties through the prototype chain. Classes in JavaScript are syntax over this mechanism.

What are call, apply and bind?

All set this. call invokes with arguments listed, apply invokes with an array of arguments, and bind returns a new function with this fixed.

What is the difference between map, filter and reduce?

map transforms every element into a new array, filter keeps elements that pass a test, and reduce combines elements into a single value.

What is debouncing?

Delaying a function until a set time has passed without new calls, useful for search inputs. Throttling instead limits a function to run at most once per interval.

What is the difference between null and undefined?

undefined means a variable was declared but not assigned. null is an intentional empty value. typeof null returns 'object' due to a historical quirk.

What are JavaScript modules?

Files that export and import values with export and import, giving each file its own scope and enabling tree-shaking in bundlers.

What is event delegation?

Attaching one listener to a parent element and using event bubbling with event.target to handle events from many child elements.

How should I prepare for a JavaScript interview?

Revise core concepts, practise output-prediction snippets, implement common utilities from scratch, and be ready to explain one project's architecture.

Related guides

Keep improving your application.

  • React Interview QuestionsThe framework round that often follows JavaScript.See React questions →
  • Frontend Developer ResumePresent your JavaScript work on your resume.View frontend resume →
  • Node.js Interview QuestionsJavaScript on the server side.See Node.js questions →

Practise JavaScript interview answers

BrainUp AI Interview Prep runs frontend mock interviews with feedback.

Start interview practiceBrowse templates

The resume builder and PDF downloads are free. AI tools are part of BrainUp Premium.