Photo by Ferenc Almasi on Unsplash

Handling events is a crucial part of any modern web application. Every developer who wants to write better code should have an in-depth knowledge of how events work, what is event bubbling and how to use event delegation to optimize event handling in our application.


Before diving deep, let’s clear out the basics first. Everyone loves to click that button see that magic happen but deep down inside JavaScript that click is an event and similar to that when the user interacts with the page, their actions are captured as events.

In order to have a button listen to an…

JavaScript is interpreted language which means we don’t have to compile it before sending it to the browser. An interpreter takes the raw code and runs it for you.

What normally used to happen was given a basic JavaScript engine which will contain a compiler whose job is to compile JavaScript source code into an intermediate representation (IR) which is usually called bytecode and this bytecode is given to interpreter.

A basic compiler job is to compile code as fast as it can and provide the interpreter with less-optimized bytecode. …

Before we get started with this article, let just recap everything we have learned so far.

Every time JavaScript wants to run a piece of code, it creates a global execution context which has two parts namely.

  1. Memory Creation Phase
  2. Code Execution Phase

First, the memory(heap) is allotted to all the variables and is given the value of undefined.

When the memory phase is done and code execution starts, all the variable are assigned their values and whenever a function needs to execute it’s being pushed in the stack and after executing the function it’s being popped off.

JavaScript is…

Website performance plays a huge role in improving the user experience of our user. This can be done pretty easily sometimes by limiting the rate of a function call and only call it when significant changes have been made.

This brings us to the topic of Debouncing and throttling and choosing the one which suits them best is crucial, as they bear different effect.

Let get basic things out of our way first

Throttling and debouncing are two ways to limit the rate of event handling.

You might ask what an event is?

Event is an action that occurs in the system. In frontend development system will be the…

Photo by Iker Urteaga on Unsplash

Do you know why you need to enclose your if statement and others as well in curly braces whenever you want to write multiple statements inside it?

That’s because you need to let JavaScript know that there are multiple statements attached where it expects only one statement.

When asked in an Interview question the question that “What is Block?”.

Most people often reply with let and const are block-scoped. While it’s true that’s not what is being asked, the question is what is a block

The block statement is often called compound statement in other languages. …

Photo by Joshua Aragon on Unsplash

What is a polyfill, and how do you go about creating one?

Let us just start with knowing what the polyfill is and why even bother knowing it.

Everyone is been in a situation where they expect few methods that browser to support natively but with every new browser coming in there are few shortcomings also.

What you will do if you found out that Chrome from next version onwards won’t support bind method that we use for function borrowing. (Don’t know function borrowing check out this).

A polyfill is a piece of code that implements the features that you expect the browser to support natively.

Now that you know what a…

Photo by Roman Synkevych on Unsplash

JavaScript binding can be done using 3 methods i.e bind(), call() and apply().

Now the question arises why 3 methods but before that why even bother learning binding concept, what is that one thing that it provides and is an absolute necessity.

One situation you might have encountered while doing your development work is having a function that does one thing and later as per new demands you want a function that does almost a similar job but on a different object.

Now you can’t just rewrite the same function and edit few variables as per need because the one…


Full Stack Developer | Working on my Startup | Loves Building weird stuff | Trying to get better at Writing and articulating my thoughts |

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