100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
JavaScript

Common JavaScript Interview Questions

A curated set of frequently asked JavaScript interview questions covering fundamentals, closures, the event loop, and ES6+ features.

Error Handling & Interview PrepIntermediate16 min readJul 8, 2026
Analogies

1. Overview

This topic collects the JavaScript questions that show up most often in technical interviews, organized as a quick-reference FAQ. Each question is paired with a concise, accurate answer you can use to check your own understanding or rehearse out loud. Read through them once for comprehension, then use the Quick Reference section to drill the one-liners right before an interview.

🏏

Cricket analogy: Like a batsman revising a coaching manual of common dismissal scenarios in the nets before facing a fast bowler, this topic collects frequent interview questions with concise answers to drill right before the real match.

2. Frequently Asked Questions

What is the difference between var, let, and const?

var is function-scoped (or globally scoped) and is hoisted with an initial value of undefined, allowing it to be referenced (but not meaningfully used) before its declaration line. let and const are block-scoped and are hoisted into a 'temporal dead zone' — they exist in scope but throw a ReferenceError if accessed before their declaration. const additionally prevents reassignment of the binding (though objects/arrays assigned to a const can still be mutated internally).

🏏

Cricket analogy: var is like a fielder placed on the pitch before the toss who can be waved at (undefined) but not bowled to, while let/const are a substitute who legally cannot step on the field (temporal dead zone) until officially named, or it's a foul.

What is a closure in JavaScript?

A closure is a function that retains access to variables from its enclosing lexical scope even after that outer function has returned. Closures are how JavaScript implements private state and factory functions — e.g. a makeCounter() function that returns an increment function which still remembers its own count variable.

🏏

Cricket analogy: A closure is like Virat Kohli's throwing arm still 'remembering' the exact release angle drilled in the nets years ago even after that practice session ended, letting a private counter like makeCounter's count persist.

Explain hoisting in JavaScript.

Hoisting is the JavaScript engine's behavior of processing variable and function declarations during the compile phase, before code executes line by line. Function declarations are hoisted completely (usable before their textual position). var declarations are hoisted with value undefined. let/const declarations are hoisted but remain in the temporal dead zone until their line executes, so accessing them earlier throws a ReferenceError.

🏏

Cricket analogy: Like the toss result being announced fully before play (function fully hoisted), while a substitute's placeholder is visible but undefined, and a suspended player is legally invisible (TDZ) until reinstated.

What is the event loop and how does it work?

The event loop is the mechanism that lets single-threaded JavaScript handle asynchronous work. Synchronous code runs first on the call stack. When it's empty, the event loop drains the microtask queue completely (Promise callbacks, queueMicrotask) before taking a single task from the macrotask queue (setTimeout callbacks, I/O, UI events), then repeats. This is why Promise.resolve().then(...) always runs before a setTimeout(..., 0) callback.

🏏

Cricket analogy: Like an umpire finishing every on-field decision (call stack) before draining the entire third-umpire review queue (microtasks), then processing only one scheduled drinks-break request (macrotask) before repeating.

What does the following code output, and why?

javascript console.log('A'); setTimeout(() => console.log('B'), 0); Promise.resolve().then(() => console.log('C')); console.log('D'); Output: A, D, C, B. Synchronous statements (A, D) run immediately on the call stack. The Promise callback is queued as a microtask and the setTimeout callback as a macrotask; the event loop drains all microtasks (C) before processing the next macrotask (B`), regardless of the 0ms delay.

🏏

Cricket analogy: Like an umpire announcing 'over' and 'drinks' instantly (A, D), then resolving every pending DRS review (C) before finally calling the scheduled strategic timeout (B), regardless of when it was requested.

What does the 'this' keyword refer to in different contexts?

this is determined by how a function is called, not where it's defined (except for arrow functions). As a plain function call, this is undefined in strict mode (or the global object otherwise). As a method call (obj.method()), this is the object before the dot. With new, this is the newly created instance. With call/apply/bind, this is explicitly set. Arrow functions have no own this — they lexically inherit it from their enclosing scope.

🏏

Cricket analogy: Like a bowler's role changing based on who calls the over — the captain's instruction (method call) sets the line, while a spectator shouting from the stands (plain call) has no binding authority at all.

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

=== (strict equality) compares both value and type with no conversion, so 1 === '1' is false. == (loose equality) performs type coercion before comparing, so 1 == '1' is true. Best practice is to default to === and only use == when coercion is explicitly desired (e.g. value == null to check for both null and undefined).

🏏

Cricket analogy: Like comparing a batter's exact jersey number to a scoreboard digit with no rounding (===, strict), versus a loose commentator's guess that shirt '10' equals score '10' after casual conversion (==).

What are prototypes and how does prototypal inheritance work?

Every JavaScript object has an internal link ([[Prototype]], accessible via Object.getPrototypeOf or the deprecated __proto__) to another object it can delegate property lookups to. If a property isn't found on the object itself, the engine walks up this prototype chain. class syntax and constructor functions with .prototype are just ergonomic ways to set up this chain — under the hood, class B extends A makes B.prototype's prototype equal to A.prototype.

🏏

Cricket analogy: Like a young player inheriting technique from their state academy coach, who inherited it from a national coach — if a shot isn't in the player's own game, they fall back on what the academy taught them.

What is the difference between null and undefined?

undefined means a variable has been declared but not assigned a value, or a property/argument simply doesn't exist. null is an explicit assignment representing 'intentionally no value.' They are loosely equal (null == undefined is true) but strictly unequal (null === undefined is false), and typeof null famously returns 'object' — a long-standing quirk of the language.

🏏

Cricket analogy: Like a scorecard slot for 'Man of the Match' left blank because it hasn't been decided yet (undefined), versus explicitly marking a rained-off match's result as 'No Result' (null) — absence versus a deliberate statement.

What are Promises and how do they differ from plain callbacks?

A Promise represents the eventual result (or failure) of an asynchronous operation as a first-class object with states pending, fulfilled, or rejected. Unlike raw callbacks, Promises can be chained with .then(), composed with Promise.all/Promise.race, and avoid 'callback hell' (deep nesting). They also standardize error propagation — a rejection skips to the next .catch() automatically instead of requiring manual error-first checks at every step.

🏏

Cricket analogy: Like a pending DRS review that will eventually resolve as 'out' or 'not out' (pending/fulfilled/rejected), letting the next decision chain automatically instead of the umpire manually re-checking after every single appeal.

What are arrow functions and how do they differ from regular functions?

Arrow functions ((a, b) => a + b) have no own this, arguments, or super — they capture these lexically from the enclosing scope, making them ideal for callbacks that need to preserve the outer this. They also cannot be used as constructors (new throws), have no prototype property, and cannot be used as generator functions.

🏏

Cricket analogy: Like a stand-in fielder who has no fielding position of their own and simply mirrors whatever position the captain assigned to the spot they're covering, never claiming an independent role.

3. Quick Reference

  • var = function scope, hoisted as undefined; let/const = block scope, temporal dead zone.
  • Closures = a function + the lexical scope it remembers, even after the outer function returns.
  • Event loop order: synchronous code → all microtasks (Promises) → one macrotask (setTimeout) → repeat.
  • === never coerces types; == does.
  • Arrow functions inherit this lexically and cannot be used with new.
  • typeof null === 'object' is a historical bug in the language, not a design choice.

4. Key Takeaways

  • Interviewers test both conceptual understanding (scoping, closures, prototypes) and code-tracing ability (event loop order, this binding).
  • Always be ready to explain the 'why' behind an answer, not just recite a definition.
  • Practice tracing asynchronous code by mentally separating the call stack, microtask queue, and macrotask queue.
  • Know the practical difference between ==/=== and null/undefined — these are near-universal warm-up questions.
  • Be able to explain this binding rules for plain calls, method calls, new, call/apply/bind, and arrow functions.

Practice what you learned

Was this page helpful?

Topics covered

#JavaScript#JavaScriptProgrammingStudyNotes#Programming#CommonJavaScriptInterviewQuestions#Common#Interview#Questions#Frequently#StudyNotes#SkillVeris

Frequently Asked Questions

21 categories · pick one to explore

Where can I get free study notes for programming and tech subjects?
SkillVeris offers completely free study notes covering programming and tech subjects, with no signup fees or paywalls. The notes are structured by course and topic, written for quick understanding, and enriched with the Learn Through Hobbies analogy method, so you can revise concepts through cricket, music, gaming, cooking and more.
Are SkillVeris study notes good for exam revision?
Yes, the study notes are designed for efficient revision: each topic answers its heading immediately, keeps explanations concise, and links to related glossary terms and cheat sheets. Students preparing for university exams or certification tests use them as quick revision notes because they distil concepts without the padding of full textbooks.
What subjects do the free study notes cover?
The study notes span the platform's main domains, including AI and machine learning, Python and programming, web development, DevOps, cloud, security and databases. Coverage mirrors the 37 live courses, so notes exist for the topics you are actually studying, and new note sets are added as courses launch.
How are SkillVeris study notes different from regular textbooks?
The notes are answer-first, concise and free, whereas textbooks are long and often expensive. Each section explains one concept directly, then reinforces it through selectable hobby analogies like cricket or cooking. Notes also cross-link to the glossary, blog and cheat sheets, letting you jump to related material instantly instead of flipping pages.
Can I use the developer study material without creating an account?
The study notes are free to access, and SkillVeris does not charge anything for its developer study material at any point. Browsing notes is straightforward from the Study Notes section, and if you want progress tracking, certificates and AI Mentor conversations tied to your learning, a free account unlocks those extras.
Do the study notes explain concepts with analogies?
Yes, this is a signature SkillVeris feature. Study notes use the Learn Through Hobbies method, explaining technical concepts through analogies from twelve domains including cricket, music, gaming, photography, travel, movies, fitness, chess, cooking, finance, business and sports. You can switch the analogy domain instantly to whichever hobby makes the concept click.
Are the revision notes suitable for last-minute exam preparation?
Yes, revision notes on SkillVeris work well for last-minute preparation because every section states the answer in its first sentences, so skimming is genuinely effective. Pair them with the relevant cheat sheet for formulas and syntax, and use the glossary for any unfamiliar term you meet while cramming.
Is there free study material for AI and machine learning?
Yes, SkillVeris provides free study notes across its AI and ML catalogue, covering Python for AI, deep learning frameworks like PyTorch and TensorFlow, Hugging Face Transformers, Large Language Models, RAG, AI agents and MLOps. All of it is free, making it a strong resource for Indian students and global learners alike.
Can beginners understand the study notes, or are they for experts?
Beginners can absolutely use them. The notes are written in plain language, define terms as they appear, and lean on hobby analogies to make abstract ideas concrete. Difficulty scales with the underlying course level, so beginner-course notes stay gentle while advanced-course notes go deeper, and the glossary supports you throughout.
How do study notes connect with SkillVeris courses?
Study notes are organised by course and topic, so they map directly to the structured courses and their 24–40-lesson curriculum. Many learners study a lesson first, then use the matching notes for revision before module assessments and the final exam, where 80 percent is required to pass and earn the certificate.
Are there study notes for Python specifically?
Yes, Python is well covered through notes tied to the Python-focused courses, including Python for AI and ML. Topics span fundamentals through applied machine learning usage. You can reinforce the notes with Python practice in Code Lab, which runs code in your browser with no installation required.
Do the study notes include code examples?
Yes, study notes include code examples wherever a concept is best shown in code, alongside explanations, key points and analogies. Reading a snippet in the notes and then reproducing it yourself in Code Lab is an effective loop, since Code Lab lets you run code in the browser across six languages.
How often is new study material added to SkillVeris?
Study material grows alongside the course catalogue. Whenever new courses join the platform's 37 live courses, matching study notes, glossary entries and cheat sheets are added so the resources stay in sync. Existing notes are also refined over time, so it is worth revisiting topics you studied earlier.
Can I use SkillVeris notes to prepare for technical interviews?
Yes, the notes make excellent interview revision because they compress each concept into direct, answer-first explanations, which mirrors how you should answer interview questions. Combine them with the SkillVeris interview questions feature, which includes readiness scoring, to test whether your revision has actually made you interview-ready.
Are the study notes mobile-friendly for studying on the go?
Yes, the study notes are built to load fast and read comfortably on mobile devices, so you can revise during a commute or between classes. Sections are short and answer-first, which suits small screens, and analogy switching works on mobile too, letting you study anywhere without carrying books.
What is the difference between study notes and cheat sheets?
Study notes explain concepts in depth with context, examples and analogies, making them ideal for learning and revision. Cheat sheets are compact quick-reference summaries of syntax, commands and key facts, ideal once you already understand a topic. Most learners study the notes first, then keep the cheat sheet handy while coding.
Do study notes help if I am stuck on a course lesson?
Yes, reading the matching study notes often clarifies a lesson because the same concept is explained from a different angle, frequently with a different analogy. If you are still stuck, ask the AI Mentor, which answers 24/7 at Quick, Detailed or Deep-dive depth until the idea genuinely makes sense.
Is there free study material for DevOps and cloud topics?
Yes, SkillVeris carries free study notes for DevOps and cloud topics as part of its coverage across 37 live courses. The material suits learners following the DevOps Engineer or Cloud Engineer paths, and it links to related glossary terms and cheat sheets so you can revise the whole toolchain in one place.
Can school or college students in India use these notes for projects?
Yes, students across India and worldwide use SkillVeris notes for coursework, projects and exam preparation, and everything is free, which matters for student budgets. The notes explain concepts clearly enough to cite in project reports, and Code Lab lets you prototype the project code directly in your browser.
How should I combine study notes with other SkillVeris resources?
A proven loop: learn from a course lesson, revise with the matching study notes, look up unfamiliar terms in the glossary, keep the cheat sheet open while practising in Code Lab, and quiz yourself with interview questions. The AI Mentor fills any remaining gaps 24/7, at whatever depth you need.

What Learners Say

Real journeys from the SkillVeris community — swipe for more.

SkillVeris taught me Python through Cricket. Now I’m building real projects and feeling confident!
Arjun S. · B.Tech Student
The best platform for hobby-based learning. Concepts finally stick.
Priya R. · Data Analyst
I went from zero coding to a portfolio of projects — all by learning through my love for gaming. Landed my first internship!
Kabir M. · CS Undergraduate
Trending Topics50 popular tags — tap to explore
Trending CoursesAll 37 free courses — tap to browse