LCWD LogoLearn Code With DurgeshLCWD
HomeCoursesBlogsContact
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...

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.

The 5 ChatGPT Prompts That Saved Me From Burnout

The 5 ChatGPT Prompts That Saved Me From Burnout

Here’s what I discovered: It wasn’t about working less. It was about working smarter. When I gave ChatGPT the right prompts, everything changed. Here are the 5 prompts that transformed my productivity:

Mastering JavaScript: Functions, Objects, Classes & Prototypes Explained Like Never Before

Mastering JavaScript: Functions, Objects, Classes & Prototypes Explained Like Never Before

If you’re learning JavaScript, you’ve probably heard terms like functions, objects, classes, constructors, inheritance, and prototypes being thrown around. But what do they really mean? And why are they so important in JavaScript? In this blog, we’ll break down these concepts step by step, with clear explanations, examples, comparisons, and diagrams. By the end, you’ll have a solid understanding of how these features work together — and why they are the backbone of modern JavaScript.

Google Tools for College Students to boost Productivity

Google Tools for College Students to boost Productivity

College life can feel like a roller coaster — assignments, exams, group projects, internships, and of course, trying to squeeze in a social life. The good news? You don’t have to do it all alone. Google has built a whole ecosystem of tools that can help students stay productive, organized, and even a little more stress-free. From taking notes to collaborating on projects, Google’s apps are like a digital toolkit every student should know about. Let’s explore how these tools can make your college journey smoother.

Can AI Make Our Food Safer Than Ever?

Can AI Make Our Food Safer Than Ever?

Every year, millions of people around the world get sick from eating contaminated food. The World Health Organization (WHO) estimates that more than 600 million people fall ill annually, and about 4.2 million die from foodborne diseases. That’s a huge number — and the scary part is, much of it comes from something we can’t even see: toxic fungi known as mycotoxins. But now, scientists may have found a way to stop this problem before it even reaches our plates. Thanks to artificial intelligence (AI) and a powerful imaging technology, our food supply could soon become safer than ever.

What is Generative AI?

What is Generative AI?

Artificial Intelligence has gone from beating humans at chess to creating human-like poetry, realistic images, and even functional code. This creative side of AI is called Generative AI — and it’s one of the most exciting areas in modern technology. But to truly understand what Generative AI means, we need to take a quick trip through history, starting with an idea that shaped all of computer science: the Turing Machine.

The Evolution of AI - From Turing to Today

The Evolution of AI - From Turing to Today

Artificial Intelligence (AI) didn’t just appear out of thin air. The chatbot answering your questions today, the recommendation system suggesting your next Netflix binge, and the self-driving cars making headlines — all of these are the result of decades of innovation, setbacks, and breakthroughs. AI’s story is one of human curiosity: a mix of science fiction dreams, brilliant engineering, and a dash of “what if machines could think?” Let’s rewind the clock and see how it all began.

HTML the Easy Way-Unlock the web

HTML the Easy Way-Unlock the web

If you’ve ever wondered how websites are built, here’s the secret: almost every webpage you see starts with HTML. Whether it’s a simple blog post, an online shop, or a social media site – HTML is the foundation.

JUnit 5 and Mockito – From Scratch to Advanced

JUnit 5 and Mockito – From Scratch to Advanced

Learn JUnit 5 & Mockito from scratch to advanced with real-time Spring Boot examples. Covers unit & integration testing, annotations, MockMvc, H2 DB, and best practices.

Modern JavaScript for Developers in 2026

Modern JavaScript for Developers in 2026

Discover the modern JavaScript features developers should know in 2026 and learn how to future-proof your skills for the evolving web landscape. This in-depth guide covers JavaScript trends 2026, emerging frameworks, and best practices to help you stay ahead in web development. Explore the top JavaScript frameworks to watch in 2026, find out what’s new in modern JS features, and see how AI-assisted JavaScript development is shaping the future. Whether you’re updating your JavaScript developer roadmap 2026 or just getting started, this article will help you master the modern JavaScript tools and techniques needed to build fast, scalable, and future-ready applications.

Debouncing in JavaScript

Debouncing in JavaScript

In this article we will learn about the debouncing . We will learn about actual real problem and how to solve this problem using js debouncing.

Maven Tutorial

Maven Tutorial

Maven is a build automation tool primarily used for Java projects. It addresses two main aspects of building software: dependency management and project build lifecycle management.

Share this article ...

💬WhatsApp📘Facebook💼LinkedIn🐦X