InterviewsVerified & Peer Reviewed

JavaScript interview questions and answers

Frontend and full-stack interviews test the same JavaScript fundamentals: scope, closures, this, asynchronous code and the event loop. Understand these well and framework questions become much easier.

J
JobsDart Editorial
2 min read

Key Takeaways

  • Explain closures, hoisting and scope with a small code example, not just a definition.
  • Know how the event loop orders synchronous code, microtasks (promises) and macrotasks (timers).
  • Understand how "this" is determined, and why arrow functions behave differently.
  • Be ready to write debounce, a promise-based delay, and array methods like map and reduce.

Fundamentals

Core JavaScript interview questions with short answers
QuestionShort answer
var vs let vs const?var is function-scoped and hoisted as undefined; let and const are block-scoped and in the temporal dead zone until declared; const cannot be reassigned.
What is hoisting?Declarations are processed before code runs, so functions and var variables can be referenced before their line.
What is a closure?A function that remembers variables from the scope where it was created, even after that scope has finished.
== vs ===?== converts types before comparing; === compares value and type, and is preferred.
null vs undefined?undefined means a value was never assigned; null is an intentional empty value.
How is "this" decided?By how a function is called: method call, plain call, new, or explicit call/apply/bind. Arrow functions take "this" from the surrounding scope.
What is prototypal inheritance?Objects inherit properties through a prototype chain; classes are syntax on top of this model.

Asynchronous JavaScript and the event loop

JavaScript runs on a single thread. Synchronous code runs first, then the event loop processes queued work: all microtasks (promise callbacks, queueMicrotask) run before the next macrotask (setTimeout, I/O events).

Common coding tasks

  • Write a debounce or throttle function
  • Implement a sleep helper: const sleep = ms => new Promise(r => setTimeout(r, ms));
  • Flatten a nested array without using flat()
  • Implement Promise.all from scratch
  • Deep-clone an object (and explain structuredClone)
  • Group an array of objects by a key using reduce

Modern JavaScript features

Expect questions on destructuring, spread and rest, optional chaining (?.), nullish coalescing (??), modules (import/export), Map and Set, and async iteration. For TypeScript roles, be ready to explain interfaces versus types and generics.

Frequently Asked Questions

Do I need to know a framework for JavaScript interviews?

Most frontend roles test React or another framework too, but strong JavaScript fundamentals are what interviewers check first.

How do I prepare for output-based questions?

Practise predicting outputs for hoisting, closures in loops, this binding and event-loop ordering, then run the code to check yourself.

Further Reading & Primary Sources

JobsDart First-Party Tools

Put This Into Practice with JobsDart Tools

Test and apply the principles from this guide directly using our dedicated career tools. Designed to eliminate guesswork and surface verified opportunities.

JobsDart Verified Job Discovery

Direct Recruiter Review

Explore verified global, remote, and corporate tech openings with direct hiring team review and real-time application tracking.

Browse Active Roles

JobsDart Free ATS Resume Checker

Instant Analysis

Validate that your resume formatting and keyword taxonomy match enterprise hiring standards before submitting.

Check Resume Match
J

JobsDart Editorial

Platform Research & Technical Editorial Board

Researched and audited by the JobsDart Technical Career Advisory Team. All guides, ATS benchmarks, and career roadmaps are tested against empirical hiring data, enterprise ATS parsers, and verified recruiter workflows.

Reviewed under JobsDart Technical Editorial StandardsLearn more about our methodology →
All Career Guides