Programming Languages (Freshers)

JavaScript Interview Questions & Answers for Freshers (2026)

JavaScript runs the web and is a top fresher hiring language for frontend and full-stack roles. These questions cover the core concepts interviewers test, with answers and a learning path to job-readiness.

JavaScript Interview Questions & Answers

Q1.What is the difference between var, let and const?easy

var is function-scoped and hoisted (initialised as undefined); let and const are block-scoped and not usable before declaration (temporal dead zone). const cannot be reassigned (though objects it points to can still mutate). Prefer const, then let; avoid var.

Q2.What is the difference between == and ===?easy

== compares after type coercion (so "5" == 5 is true), while === compares value and type with no coercion (so "5" === 5 is false). Prefer === to avoid surprising bugs.

Q3.Explain closures.medium

A closure is a function that remembers variables from the scope where it was created, even after that scope has returned. Closures power data privacy, function factories and callbacks. Example: a counter function that keeps a private count variable.

Q4.What is the difference between null and undefined?easy

undefined means a variable has been declared but not assigned (the default). null is an intentional "no value" you assign yourself. typeof undefined is "undefined"; typeof null is "object" (a historical quirk).

Q5.What is hoisting?medium

Hoisting moves declarations to the top of their scope at compile time. Function declarations are fully hoisted; var declarations are hoisted but initialised as undefined; let/const are hoisted but stay in the temporal dead zone until declared.

Q6.Explain the event loop.hard

JavaScript is single-threaded. The event loop runs synchronous code on the call stack, then processes the microtask queue (promises) and macrotask queue (setTimeout, events). This lets async work complete without blocking the main thread.

Q7.What are promises and async/await?medium

A promise represents a future value (pending → fulfilled/rejected). async/await is syntax sugar over promises: await pauses an async function until a promise settles, making async code read like synchronous code. Use try/catch for errors.

Q8.What is the difference between map, forEach and filter?easy

forEach runs a function per element and returns undefined (side effects). map returns a new array of transformed values. filter returns a new array of elements that pass a test. map and filter are pure and chainable.

Q9.Explain "this" in JavaScript.medium

"this" refers to the object that called the function. In a method it is the object; alone or in a regular function it is the global object (or undefined in strict mode); arrow functions do not bind their own this — they inherit it from the enclosing scope.

Q10.What is the difference between a regular function and an arrow function?medium

Arrow functions are shorter, do not have their own this/arguments (they inherit this lexically), and cannot be used as constructors. Regular functions have their own this determined by how they are called.

Q11.What is event delegation?medium

Instead of adding listeners to many child elements, you add one listener to a common parent and use event.target to detect which child was clicked. It improves performance and works for dynamically-added elements.

JavaScript — Self-Learning Path

1. Fundamentals

Variables (let/const), data types, operators, conditionals, loops, and functions. Understand truthy/falsy values and type coercion.

2. Functions & scope

Function expressions vs declarations, arrow functions, closures, the call stack, and hoisting. These appear in almost every interview.

3. Objects, arrays & ES6+

Object/array literals, destructuring, spread/rest, template literals, and array methods (map, filter, reduce, find, some, every).

4. Asynchronous JavaScript

Callbacks → promises → async/await, the event loop, fetch and error handling. Build something that calls an API and renders the result.

5. The DOM & events

Select and manipulate elements, add event listeners, event delegation and bubbling. Build a small interactive UI (to-do list).

6. Practice & build

Build 2–3 projects (to-do app, weather app using fetch, a small quiz). Solve easy array/string problems to sharpen fundamentals.

Interview Tips

  • Be able to explain closures and the event loop clearly — they are the most-asked topics.
  • Prefer === and const; explain why.
  • Practise array methods (map/filter/reduce) by transforming data.
  • Know how async/await maps to promises.

Ready to apply what you’ve learned?

Browse fresh internships and first jobs in JavaScript and related fields.

Browse Internships