Career guides · Skill guide

JavaScript interview
questions for freshers

Web and full-stack interviews in 2027 test JavaScript fundamentals before any framework: scope and closures, hoisting, types and equality, this and arrow functions, arrays and objects, promises and async/await, the event loop, modules, and DOM events. Freshers are asked to explain these and solve small coding tasks. Practise output-prediction questions and small vanilla projects, and prove your basics with a verified test before you apply.

By , FounderUpdated 8 min read

Share

Quick answer: What JavaScript questions do interviews ask freshers, and how should I answer?

  1. Language basics — let/const/var, scope, hoisting, types, == vs ===, truthiness.
  2. Functions — closures, this, arrow functions, call/apply/bind, higher-order functions.
  3. Async — callbacks, promises, async/await, the event loop and microtasks.
  4. Browser — DOM selection and updates, events, bubbling and delegation, fetch.
  5. Most used — JavaScript is the most-used language among professional developers (Stack Overflow, 2025).

Key takeaways

  • Framework interviews still start with plain JavaScript — fundamentals decide the first round.
  • Output-prediction questions on closures, this and the event loop are standard; practise explaining, not guessing.
  • Small vanilla JavaScript projects build the skills frameworks hide.
  • Async errors and race conditions separate prepared freshers from the rest.
  • A verified fundamentals score is a quick signal for career-switchers without CS degrees.

Picture a front-end interview for freshers at a Noida product company. The first question isn't about React at all. The interviewer types five lines — a for loop with var, a setTimeout inside, and console.log(i) — and asks what prints. Most candidates say 0, 1, 2. It prints 3, 3, 3. The candidate who explains why (var is function-scoped, so every callback closes over the same variable; let creates a new binding per iteration) moves to the next round. JavaScript interviews for freshers are full of moments like this, and every one of them can be learned.

What JavaScript questions do interviews ask freshers, and how should I answer? At a glance: Language basics; Functions; Async; Browser; Most used.
At a glance: What JavaScript questions do interviews ask freshers, and how should I answer?

Why JavaScript fundamentals decide web interviews

JavaScript is the most-used language among professional developers in Stack Overflow's 2025 survey, alongside HTML and CSS.5 Every front-end framework — React, Angular, Vue — and Node.js on the server is JavaScript underneath, so interviewers test the language first. Candidates who know a framework but not closures, this or the event loop rarely pass the first technical round.

The jobs these fundamentals open are plentiful in India: AmbitionBox lists about 68,600 front-end developer salaries alone, with typical pay of ₹6.1–6.7 lakh in October 2026.6

JavaScript's rank among most-used languages by professional developers (Stack Overflow, 2025)
#1
Typical front-end developer pay in India (AmbitionBox, Oct 2026)
₹6.1–6.7 lakh
Front-end developer salaries on AmbitionBox
~68,600
Where JavaScript fundamentals are tested
1st round

How JavaScript is tested

FormatExampleWhat they check
Output prediction"What does this print?"Scope, closures, this, event loop
Concept questions"Explain closures with an example."Clear understanding
Small coding tasksDebounce, flatten an array, deep cloneProblem-solving in JS
DOM tasksBuild a todo list or tabs without a frameworkBrowser fundamentals
Async tasksFetch with retries, run promises with a concurrency limitAsync correctness

Table: How JavaScript is tested in interviews (editorial summary)

What a fundamentals test covers

What a fundamentals test covers: Scope and hoisting; Types and equality; Functions and closures; this; Async; Modules and the DOM.
What a fundamentals test covers

Scope and hoisting

let and const are block-scoped; var is function-scoped and hoisted; the temporal dead zone.

Types and equality

Primitive vs reference types, == vs ===, truthy and falsy values, typeof quirks.

Functions and closures

Closures, higher-order functions, default and rest parameters.2

this

Method calls, plain calls, new, call/apply/bind, and arrow functions' lexical this.

Async

Callbacks, promises, async/await, error handling and the event loop.3

Modules and the DOM

ES modules, querySelector, events, bubbling and delegation, fetch.

MDN's JavaScript Guide is the best free reference,1 and the ECMAScript specification is the final word when behaviour is surprising.4

Worked example: debounce, explained

A favourite fresher task: "Write a debounce function."

function debounce(fn, delay) {
  let timer;
  return function (...args) {
    clearTimeout(timer);
    timer = setTimeout(() => fn.apply(this, args), delay);
  };
}

const onSearch = debounce((q) => console.log("search", q), 300);

What to say: the returned function closes over timer, so every call shares it; each call cancels the previous timer, so fn runs only after 300 ms of quiet; apply preserves this and arguments. Then mention edge cases — a leading-edge option, cancelling, and why it's useful for search boxes and resize events.

JavaScript interview questions, with how to answer them

"What prints: for (var i = 0; i < 3; i++) setTimeout(() => console.log(i));"

3, 3, 3 — var is shared across iterations and the callbacks run after the loop ends. With let, it prints 0, 1, 2 because each iteration gets a new binding.

"Explain hoisting."

Declarations are processed before code runs: var declarations are hoisted and initialised to undefined; function declarations are hoisted fully; let and const are hoisted but not initialised (temporal dead zone).

"What's the output order of a setTimeout(0) and a resolved promise?"

The promise callback first — microtasks run before the next macrotask.

"Difference between map, forEach, filter and reduce?"

map returns a new array of transformed items; forEach just iterates; filter returns items that pass a test; reduce combines items into one value.

"How do you copy an object?"

Spread or Object.assign for shallow copies; structuredClone for deep copies of plain data.

"What is event delegation?"

Attaching one listener to a parent and using event.target to handle events from many children — efficient and works for elements added later.

"Why use async/await over .then()?"

It reads like synchronous code and makes try/catch error handling simpler; underneath it's still promises.

"What is a pure function?"

One that returns the same output for the same input and has no side effects — easier to test and reason about.

How JavaScript expectations have changed

PeriodWhat happenedWhat interviews tested
2005–2011AJAX and jQuery eraDOM scripting, cross-browser quirks
2012–2015Node.js, single-page appsClosures, prototypes, callbacks
2015–2019ES2015+: let/const, arrow functions, promises, classes, modulesModern syntax, promises
2020–2024async/await everywhere; TypeScript commonAsync correctness, types
2025–2027AI writes routine JSExplaining and debugging code you didn't write

Table: How JavaScript interview expectations have changed (editorial summary)

Practice tasks that build JavaScript skill

  1. Output drills — Fifty output-prediction snippets on scope, this and the event loop; explain each aloud.
  2. Utility functions — Write debounce, throttle, deep clone, flatten and a simple promise pool from scratch.
  3. A vanilla app — Build a filterable list with fetch, loading and error states, and event delegation — no framework.
  4. Async race — Build a search that ignores out-of-order responses using AbortController.
  5. Read the spec once — Look up one surprising behaviour in the ECMAScript specification.
Readiness check · SOA-JS

Could you pass the JavaScript Fundamentals Certification today?

Hiring managers test judgement with scenarios like this one. Answer it before you open the explanation — the test has 10 of them, 10 minutes, 70% to pass.

What does typeof null return in JavaScript?

  1. "object"
  2. "null"
  3. "undefined"
  4. "number"
Show the answer

A. "object" — A long-standing quirk of the language; check for null explicitly.

  1. 01Language basics
  2. 02Async and the browser
Difficulty: Beginner

Free, no sign-up. Pass and you become a JavaScript Fundamentals, with a credential ID employers can verify. Every answer is explained either way.

Where JavaScript takes your career

Role (India)Typical payHow JavaScript is used
Front-end developer₹6.1–6.7 lakhUI and browser logic
React developer₹5.7–6.3 lakhComponents and state
Node.js developer₹6.9–7.6 lakhServer-side JavaScript
Full-stack developer₹9.2–10.2 lakhBoth sides of the stack
Bar chart: Where JavaScript takes your career — Front-end developer: ₹6.1–6.7 lakh; React developer: ₹5.7–6.3 lakh; Node.js developer: ₹6.9–7.6 lakh; Full-stack developer: ₹9.2–10.2 lakh.
Where JavaScript takes your career

Table: JavaScript-based roles and typical pay in India (AmbitionBox, October 2026; indicative)

A four-week plan

Diagram of 4 steps for a four-week plan: 1. Week 1: Language core; 2. Week 2: Data and modules; 3. Week 3: Async and DOM; 4. Week 4: Practice and proof.
A four-week plan
  1. Week 1: Language core — Scope, types, functions, closures, this.
  2. Week 2: Data and modules — Arrays, objects, destructuring, spread, ES modules.
  3. Week 3: Async and DOM — Promises, async/await, event loop, fetch, events.
  4. Week 4: Practice and proof — Output drills and small tasks; take the JavaScript Fundamentals Certification.

Next: the TypeScript test, the HTML and CSS test and React Developer Assessment; our guides on front-end and Node.js jobs show where they lead.

How JavaScript shows up at work

  • Debugging async bugs — race conditions between API calls, stale state and unhandled promise rejections.
  • Reading framework code — understanding what React, Angular or Vue does with your functions and closures.
  • Performance work — avoiding unnecessary work on the main thread and in event handlers.
  • Browser APIs — fetch, storage, events and observers used directly or through libraries.
  • Code review — catching == comparisons, accidental mutation and this-binding mistakes.
  • Utilities — writing small, well-tested helpers instead of pulling in large libraries.

More questions interviewers ask

"What is the difference between null and undefined?"

undefined means a variable was declared but not assigned (or a missing property); null is an intentional "no value". typeof null is "object" for historical reasons.

"What does the spread operator do?"

It expands arrays or objects into individual elements or properties — useful for copying, merging and passing arguments. Copies are shallow.

"What is a higher-order function?"

A function that takes or returns another function, such as map, filter or a debounce wrapper.

"How do you handle errors with async/await?"

Wrap awaits in try/catch, handle rejections close to where you can act on them, and use Promise.allSettled when partial failure is acceptable.

"What is the difference between call, apply and bind?"

call and apply invoke a function immediately with a chosen this (apply takes arguments as an array); bind returns a new function with this fixed for later.

Mistakes that cost candidates

  • Guessing output instead of reasoning aloud.
  • Confusing == and ===.
  • Not knowing what this refers to.
  • Ignoring promise errors.
  • Only knowing a framework.

How we know

Technical references are MDN's JavaScript Guide (including closures and promises) and the ECMAScript specification; usage data from Stack Overflow's 2025 survey; pay from AmbitionBox (read October 2026). Test formats and the history table are editorial summaries. Science of Apps publishes the free certification linked here. Last reviewed October 2026.

Key terms, defined

  • Closure — a function that keeps access to variables from where it was created.
  • Hoisting — declarations being processed before code runs.
  • Event loop — the mechanism that runs queued tasks when the call stack is empty.
  • Promise — an object representing a value that will be available later.
  • Event delegation — handling events from many children with one parent listener.

Frequently asked questions

What JavaScript topics should a fresher know?

Variables and scope (let, const, var), data types and equality, functions and closures, this and arrow functions, arrays and objects with their common methods, promises and async/await, the event loop, ES modules, and DOM manipulation with events. These come up in nearly every front-end and full-stack interview.

What is a closure in JavaScript?

A closure is a function that remembers the variables from the scope where it was created, even after that scope has finished running. Closures power data privacy, function factories and callbacks, and explain classic bugs like loops with var capturing the same variable.

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

=== compares value and type without conversion; == converts types before comparing, which produces surprising results such as 0 == '' being true. Use === by default.

How does this work in JavaScript?

this depends on how a function is called: the object before the dot for method calls, undefined in strict-mode plain calls, a new object with new, and an explicitly set value with call, apply or bind. Arrow functions don't have their own this; they use the surrounding scope's.

What is the event loop?

JavaScript runs on a single thread. The event loop runs queued work when the call stack is empty: first all microtasks (like promise callbacks), then the next macrotask (like a timer or event). This explains why a resolved promise's callback runs before a zero-delay setTimeout.

How do I prepare for a JavaScript interview in a month?

Spend the first two weeks on fundamentals with MDN and small exercises, the third on async and the DOM with a vanilla project, and the fourth on timed output questions and small coding tasks, explaining your reasoning aloud. Take a short verified test to find gaps.

Sources

  1. MDN Web Docs — JavaScript Guide
  2. MDN Web Docs — Closures
  3. MDN Web Docs — Using promises
  4. Ecma International — ECMAScript Language Specification (TC39)
  5. Stack Overflow — 2025 Developer Survey, Technology
  6. AmbitionBox — Front end Developer salaries in India (updated 24 Oct 2026)
  7. Checked October 28, 2026. Figures that change — fees, salaries, prices — are reviewed every six months; if something is out of date, tell us.
Pass it on

Know someone who'd enjoy this?

Send it to them — one tap, no sign-up. Good ideas travel best between friends.

Keep exploring

Certifications to take next

Keep exploring

Career guides for related roles

Join free

Get the ideas, not the noise.

Sign up with Google and we’ll send you short UX psychology tips by email — why people tap, stall and leave, and what to do about it. Unsubscribe anytime. Prefer something to keep? Get the free Laws of UX guide as a PDF.

Get the free Laws of UX PDFFree · no spam · unsubscribe anytime
Prove you're ready

You've read the playbook. Now prove it.

Take the free JavaScript Fundamentals Certification and earn JavaScript Fundamentals (SOA-JS). Free, test-based certifications graded on our server. Pass and you get a founder-signed certificate with a credential ID and QR code employers can verify.

Free · SOA-JS

Become a JavaScript Fundamentals.

Tests core modern JavaScript — variables and scope, types and equality, functions and closures, arrays and objects, promises and async/await, modules and the DOM. Graded on our server, with a founder-signed certificate, a credential ID and a QR code anyone can verify.

  • Credential ID
  • QR verification
  • LinkedIn-ready
Free PDF · 74 pages · 2 editions

The Laws of UX, in one field guide

60 research-backed principles in 6 categories — what each one means, why it works on the human brain and how to use it on your own screens. Written by Sushant Singh, founder of Science of Apps, who has scaled consumer apps to lacs of users and spent 10+ years leading product across startups and digital businesses in the US, EU & India.

Pick your edition
Free. No card, no paywall — just your email.
Free PDF · 74 pages

Get Laws of UX by email

Choose your edition

You’ll also get occasional UX psychology tips. Unsubscribe anytime. Privacy policy

Free PDF · 90 pages · 2 editions

100+ Subscription Paywalls, decoded

110 real paywalls from top apps, taken apart, rated out of 5 and decoded with the Laws of UX — plus the frameworks, copy and checklists to ship your own. By Sushant Singh, founder of Science of Apps.

  • 110 paywalls rated
  • 34 Laws of UX
  • 12 frameworks

Which paywall scored 4.8 out of 5, and which scored 2.6? It’s all inside.

Pick your edition
Free. No card, no paywall — just your email.
Free PDF · 90 pages

Get 100+ Paywalls, Decoded by email

Choose your edition

You’ll also get occasional UX psychology tips. Unsubscribe anytime. Privacy policy