LCWD LogoLearn Code With DurgeshLCWD
HomeCoursesTutorialsBlogsContact
About LCWDAbout Durgesh Tiwari
Flex Box Hero
LearnCodeWithDurgesh Logo

Learn Code With Durgesh

Offering free & premium coding courses to lakhs of students via YouTube and our platform.

Explore

  • About Us
  • Courses
  • Blog
  • Contact
  • FlexBox Game

Legal

  • Privacy Policy
  • Terms & Conditions
  • Refund Policy
  • Support

Contact

  • 📞 +91-9839466732
  • [email protected]
  • Substring Technologies, 633/D/P256 B R Dubey Enclave Dhanwa Deva Road Matiyari Chinhat, Lucknow, UP, INDIA 226028
© 2025 Made with ❤️ by Substring Technologies. All rights reserved.
Ace Your Coding Interview: JavaScript Q&A for Intermediate Learners

Ace Your Coding Interview: JavaScript Q&A for Intermediate Learners

By Shruti • Fri Aug 22 2025

Ace Your Coding Interview: JavaScript Q&A for Intermediate Learners

1. What are closures in JavaScript?

A closure is when a function can remember and use variables from its outer scope, even after that scope has finished.

function counter() {
  let count = 0;
  return function() {
    count++;
    return count;
  };
}
const add = counter();
console.log(add()); // 1
console.log(add()); // 2

2. Difference between call(), apply(), and bind()?

  • call() → calls the function immediately, pass arguments one by one.
  • apply() → same as call, but pass arguments as an array.
  • bind() → returns a new function with this fixed, doesn’t run immediately.

3. Explain the event loop.

The event loop makes JavaScript handle tasks in order:

  1. Run all normal code first (synchronous).
  2. Then handle microtasks (like Promises).
  3. Then handle macrotasks (like setTimeout).

4. Difference between synchronous and asynchronous code?

  • Synchronous: runs step by step, one after another.
  • Asynchronous: doesn’t block; code runs in background (like API calls, setTimeout).

5. What is Promise.all() vs Promise.race()?

  • Promise.all() → waits for all promises to finish (resolves if all succeed).
  • Promise.race() → gives the result of the first promise that finishes.

6. Shallow copy vs deep copy?

  • Shallow copy: top-level values are copied, but nested objects are still linked.
  • Deep copy: creates a complete, independent clone.

7. What is this in JavaScript?

  • In global → window (in browser).
  • Inside an object method → that object.
  • Inside arrow function → comes from outer scope (doesn’t create its own).

8. Difference between map(), filter(), reduce()?

  • map() → transforms every element.
  • filter() → picks elements that match condition.
  • reduce() → combines all into a single value.

9. What are arrow functions?

Shorter syntax for writing functions. They don’t have their own this; they use this from outer scope.


10. Difference between for...in and for...of?

  • for...in → goes through object keys.
  • for...of → goes through iterable values (like arrays).

11. What is prototypal inheritance?

Objects can inherit properties and methods from another object (its prototype).


12. What are IIFEs?

Immediately Invoked Function Expressions. Functions that run as soon as they’re defined.


13. What are higher-order functions?

Functions that take other functions as arguments, or return a function.


14. What is debouncing vs throttling?

  • Debounce → runs only after the user stops triggering it (useful for search input).
  • Throttle → makes sure a function runs at most once in a given time (useful for scroll events).

15. How do you remove duplicates from an array?

By using a Set:

let arr = [1,2,2,3];
let unique = [...new Set(arr)]; // [1,2,3]

16. Difference between localStorage, sessionStorage, and cookies?

  • localStorage → saved permanently in the browser until cleared.
  • sessionStorage → only for that browser tab session.
  • cookies → small data stored, also sent with every request to the server.

17. What is a JavaScript module?

A module is reusable code that can be imported/exported across files using import and export.


18. Difference between null, undefined, and NaN?

  • null → intentional empty value.
  • undefined → variable declared but no value assigned.
  • NaN → result of invalid math (Not-a-Number).

19. How do async/await work?

They are a cleaner way to work with Promises. Code looks synchronous, but actually runs asynchronously.


20. What are generators?

Special functions that can pause and resume using yield. They return an iterator object.


21. What is memoization?

Storing the result of expensive function calls so you don’t have to calculate again if the same input repeats.


22. setTimeout vs setInterval?

  • setTimeout → runs code once after given time.
  • setInterval → runs code repeatedly after each interval.

23. Difference between Object.freeze() and Object.seal()?

  • freeze() → you can’t change, add, or delete properties.
  • seal() → you can update values, but can’t add or remove properties.

24. What is event delegation?

Instead of adding event listeners to many child elements, you add it once to a parent, and check the target inside.


25. What are WeakMap and WeakSet?

They are like Map and Set but hold weak references to objects. If the object is no longer used, it gets garbage-collected automatically. Useful for caching or private data.

Share this article ...

💬WhatsApp📘Facebook💼LinkedIn🐦X

Trending Blogs...

AI: Boon or Curse? Advantages & Disadvantages Explained

AI: Boon or Curse? Advantages & Disadvantages Explained

Artificial Intelligence (AI) is no longer just a concept of the future—it is already shaping our present. From asking Alexa or Siri to play music, using Google Maps for directions, or experiencing personalized recommendations on Netflix, AI has become a part of our everyday life.

The Future of Technology: Quantum Computing and Its Ecosystem

The Future of Technology: Quantum Computing and Its Ecosystem

Quantum computing isn’t just another buzzword—it’s a completely new way of thinking about computers. Unlike our everyday laptops or phones that run on classical computing, quantum computers use the strange but powerful rules of quantum mechanics.

Tailwind CSS Cheat Sheet – Complete Utility Class Guide 2025

Tailwind CSS Cheat Sheet – Complete Utility Class Guide 2025

Tailwind CSS Cheat Sheet – Complete Utility Class Guide 2025

Expert-Level JavaScript Interview Q&A for 2025: Crack Advanced JS Interviews

Expert-Level JavaScript Interview Q&A for 2025: Crack Advanced JS Interviews

Get ready for tough coding interviews with this collection of advanced JavaScript interview questions and answers. Designed for experienced developers who want to master complex JS concepts and impress recruiters.

Ace Your Coding Interview: JavaScript Q&A for Intermediate Learners

Ace Your Coding Interview: JavaScript Q&A for Intermediate Learners

Prepare for your next coding interview with this collection of JavaScript interview questions and answers for intermediate developers. Strengthen your JS concepts and boost your confidence.

Most Asked JavaScript Interview Questions with Answers

Most Asked JavaScript Interview Questions with Answers

Q1. What is JavaScript? JavaScript is a programming language mainly used to make web pages interactive and dynamic. It runs in the browser, and with Node.js, it can also run on the server.

Share this article ...

💬WhatsApp📘Facebook💼LinkedIn🐦X