HomeInterview QuestionsJavaScript Interview QuestionsTop 10
🟨
Free Study Guide · 2025

Top 10 JavaScriptInterview Questions & Answers (2025)

JavaScript is asked in every frontend, full-stack, and even backend role. These questions cover core concepts that interviewers at TCS, Infosys, Razorpay, CRED, and every FAANG company test in their JavaScript rounds.

10 questions
Detailed answers
100% free
Also available:Top 20All 25 questions →
1What is the difference between var, let, and const?
var is function-scoped, gets hoisted with a value of undefined, and can be re-declared. let and const are block-scoped (within {}), are hoisted but not initialised (temporal dead zone), and cannot be re-declared. const additionally prevents reassignment of the variable binding — though the object it points to can still be mutated.
2What is hoisting in JavaScript?
Hoisting is JavaScript's behaviour of moving variable and function declarations to the top of their scope during compilation, before code executes. Function declarations are fully hoisted (callable before they appear). var variables are hoisted and initialised to undefined. let and const are hoisted but remain uninitialised (accessing them before declaration throws a ReferenceError — the temporal dead zone).
3What is a closure?
A closure is a function that retains access to its outer (enclosing) function's variables even after that outer function has finished executing. JavaScript creates closures every time a function is created. They're used for data privacy (module pattern), factory functions, memoization, and in callbacks/event handlers where you need to 'remember' surrounding context.
4What is the JavaScript event loop?
JavaScript is single-threaded. The event loop continuously checks: if the call stack is empty, it takes the first task from the callback queue (or microtask queue first) and pushes it onto the stack. Microtasks (Promise callbacks, queueMicrotask) run before macrotasks (setTimeout, setInterval). This is why a resolved Promise callback runs before a setTimeout(fn, 0) callback.
5What is the difference between == and ===?
== is the loose equality operator and performs type coercion before comparing — 0 == '0' is true. === is the strict equality operator and returns false if the types differ — 0 === '0' is false. Always prefer === to avoid subtle bugs from unexpected type coercions. The only common exception is null == undefined (both are true with ==).
6What is a Promise and how does it work?
A Promise represents the eventual result of an asynchronous operation. It has three states: pending, fulfilled (resolved with a value), or rejected (with a reason). You chain .then() for the success case, .catch() for errors, and .finally() to run code regardless. Promise.all() runs multiple promises in parallel; Promise.race() resolves/rejects as soon as one settles.
7What is async/await and how does it relate to Promises?
async/await is syntactic sugar over Promises that lets you write asynchronous code that reads like synchronous code. An async function always returns a Promise. await pauses execution of the async function until the Promise resolves, then returns the resolved value. Use try/catch around await for error handling. It doesn't replace Promises — it's built on top of them.
8What is the difference between null and undefined?
undefined means a variable has been declared but not assigned a value (also the default return value of functions). null is an intentional assignment meaning 'no value' — you explicitly set something to null to indicate emptiness. typeof undefined === 'undefined' but typeof null === 'object' (a long-standing JS quirk). Use === null or === undefined to check for them specifically.
9What is the prototype chain in JavaScript?
Every JavaScript object has an internal [[Prototype]] link to another object (or null). When you access a property, JS looks at the object first, then walks up the prototype chain until it finds the property or reaches null. This is how inheritance works in JS — Array.prototype methods like .map() are available on all arrays through this chain.
10What is the 'this' keyword in JavaScript?
'this' refers to the object that is executing the current function. In a method, this is the object the method belongs to. In a regular function, this is the global object (or undefined in strict mode). Arrow functions don't have their own this — they inherit it from the enclosing scope. Call, apply, and bind explicitly set what this refers to.
See all 25 JavaScript questions →
Level up your prep
Get company-specific JavaScript questions
Upload your resume → get questions tailored to Google, Amazon, TCS, and 50+ companies.
Try AI Interview Prep →
© 2025 CareerLens · Home · Interview Questions · Pricing