Debounce in JavaScript

Photo by Kevin Mueller on Unsplash

Today on 5th December 2020, JavaScript celebrates its 25th Birthday and I thought of explaining one of the most important topics a JavaScript Developer should know about, Debounce function.

What is a Debounce function?

The debounce() function forces a function to wait a certain amount of time before running again. The function is built to limit the number of times a function is called.

To understand this, let’s take an example of an auto-complete or type-ahead. (We will build our own auto-complete in this article).

So, suppose you have an autocomplete, now to show the dropdown options you will have to fire an API on…

After going through the title you might think, why are we even using JavaScript to implement a Linked List, why can’t we just use C++ or Java which support prebuilt DS functions? To be honest, you are not wrong, JavaScript does not support Object-Oriented Programming (OOP) and it does not have any built-in functions for any Data Structures (except Arrays), however with ES-2015, a new class keyword was introduced and we will be taking advantage of that. But again, is implementing Data Structures really hard & is it even worth our efforts? …

Welcome to Part I of the Docker Series where we will learn about all the basic commands which you need to master, to then containerize your docker applications. I know learning these commands might be a bit tedious, but I have tried my best to explain everything incisively. At the end of this article, you’ll also find a cheat sheet of all the docker commands which you can refer at any point in time.

In this part of the Docker Series, we will learn the following

  • What is Docker and why do we even use it?
  • What are Containers?
  • What…

Which state management solution is right for your project?

Redux vs. Context API.
Redux vs. Context API.
Photo by the author.

Redux is a library that is used in almost every React application, but do we even need it? The simple answer to this question will be “Yes, as it helps our state management.” This is not wrong, but do we have an alternative?

Fortunately, we do. As a JavaScript developer, I have come to understand that we aren’t satisfied with just one thing. We need alternatives. That is why React 16.4 offered us the Context API.

This article will help you understand and answer the most common questions about state management:

  • Why can’t we just use props to manage state…

Welcome to the blog where I answer the most asked JavaScript Interview question, after Life Cycles of course :P.

What are callbacks, promises, and async-await? Which one is better and how to implement these?

*Also something extra for Angular Developers on what are Observables and how do they differ from Promise.*

First thing first, JavaScript by default runs synchronously but then why do we need to run it asynchronously? For this to understand, let’s see how actually is the synchronous operation performed in JS.

Guess what will be the output for the below code block.

function callMe() {

Easy, right? The output will be, a b c.

But how does…

React Refs are a useful feature that acts as a means to reference a DOM element.

But the question here is why can we not directly manipulate the DOM using normal JavaScript DOM Manipulation?

Here is an example of why normal JS DOM Manipulation won’t be as useful as Refs when it comes to using React.

Suppose you have a component which has multiple input element. Now, what if we want to focus on the second input element or any other input element as soon as we render the component?

What happens when we use normal JS DOM Manipulation?


Akhilesh Ojha

JavaScript Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store