article blog.rubyonrails.ba
🧠 Top 20 JavaScript Interview Questions and Answers for 2025 20/07/2025 ~ Views: 308
1. What is the difference between var, let, and const?

var is function-scoped, while let and const are block-scoped.
 const cannot be reassigned after declaration, while let can.

2. What is a closure in JavaScript?

A closure is a function that remembers its outer variables even after the outer function has finished executing.
 Used for data privacy and currying.

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

== checks for value equality (with type coercion),
 === checks for both value and type.

4. Explain the event loop in JavaScript.

The event loop handles asynchronous tasks in JavaScript.
 It processes the call stack, and once it’s empty, it pushes callback functions from the task queue into the call stack.

5. What is hoisting?

JavaScript moves declarations (not initializations) to the top of their scope.
 var declarations are hoisted, but let and const are hoisted without initialization.

6. What is the difference between null and undefined?

  • undefined: a variable declared but not assigned.

  • null: explicitly assigned value representing no value.

7. What is the difference between call(), apply(), and bind()?

  • call: invokes a function with a given this and arguments.

  • apply: same as call but arguments are in an array.

  • bind: returns a new function with bound this.

8. What are arrow functions and their limitations?

Arrow functions provide shorter syntax and do not bind their own this, arguments, or super.
They can't be used as constructors.

9. What is the this keyword in JavaScript?

this refers to the object from which a function is called.
 Its value depends on how a function is invoked (global, object, constructor, etc.).

10. What is the purpose of async and await?

Used to write asynchronous code that looks synchronous.
 await pauses execution until the Promise resolves.

11. What is a Promise and how does it work?

A Promise represents a value that may be available now, or in the future, or never.
 It has 3 states: pending, fulfilled, rejected.

12. What is event delegation?

A pattern where a parent element handles events from its child elements, using event bubbling.
 Improves performance and simplifies event handling.

13. What is the difference between deep copy and shallow copy?

  • Shallow copy copies only references to nested objects.

  • Deep copy duplicates every nested object fully (e.g., structuredClone, JSON.parse(JSON.stringify(...))).

14. What is destructuring in JavaScript?

A shorthand for extracting values from arrays or objects.
 Example: const {name, age} = user;

15. What is optional chaining (?.) in JavaScript?

It allows safe access to deeply nested properties.
 Example: user?.profile?.email avoids runtime errors if profile is undefined.

16. What is a pure function?

A function that always returns the same output for the same input and causes no side effects.

17. How does setTimeout work under the hood?

setTimeout pushes the callback into the task queue after the delay, but not exactly on time, since execution depends on the event loop.

18. What is the difference between map() and forEach()?

  • map() returns a new array.

  • forEach() executes a function for each item but does not return anything.

19. What is a higher-order function?

A function that takes another function as argument or returns a function.
 Examples: map, filter, reduce.

20. What is the difference between synchronous and asynchronous code?

  • Synchronous: tasks run one after another.

  • Asynchronous: tasks may run independently (e.g., timers, AJAX calls, Promises).

📘 Want the Full Guide with 1000+ Questions?

This is just a taste of what real tech interviews in 2025 look like.

🛠 Bonus Included in Full eBook:

  • Behavioral interview questions

  • Coding challenges with solutions

  • Real-world system design tasks

Find more interviewing ebooks on interviewbible.com

Tags: #javascript #interview #jobinterview #reactjs

Back

OPEN TO HIRE
yes blog.rubyonrails.ba
Nezir Zahirovic
Ruby On Rails Full stack last 10 years.
C#, ASP.NET, JavaScript, SQL, CSS, Bootstrap 11 years.

Top articles

⚛️ Top 20 React JS Interview Questions and Answers for 2025 >>>
🐍 Top 20 Python Interview Questions and Answers for 2025 >>>
🔴 Top 20 Ruby on Rails Interview Questions and Answers fo... >>>
🧠 Top 20 JavaScript Interview Questions and Answers for 2025 >>>
What's the Fucking Clean Code??? >>>