Photo by Pankaj Patel on Unsplash

If you are a beginner in JavaScript, it is really important to understand the concept of closures. It will save you hours of debugging.

Before we dive into the world of closures, we need to make sure that we are comfortable with the idea of scope in JavaScript.

What is the scope?

Imagine that you are chatting with two friends, A and B, on Facebook. Whatever messages you send to A, B does not have access to them. The same goes for A. But if you create a group then everyone can see or have access to all the messages. This is because these…

Reducer flow, collected from

In part 1, we saw how we could set up a simple controlled React form. We used the ‘useState’ hook to store our form inputs. It looked like this:

But what would happen if the form grew bigger? What if there were multiple inputs? Our ‘handleChange’ function would look messy. Also, it would be hard to handle complex form logic.

form with useState hook

Here comes the ‘useReducer’ hook! This is an alternative to ‘useState’. According to the official React documentation:

useReducer is usually preferable to useState when you have complex state logic that involves multiple sub-values or when the…

Forms in React are similar to the standard HTML forms in terms of syntax. There are two types of forms in React: controlled and uncontrolled. In controlled form, we store the data in the state, and the form derives its input values from the state. But in uncontrolled form, we do not store any data in the state. In this article, I am going to explain how we can use the controlled form in React.

For each input, we will need a corresponding state to store the input value and a function to handle the input change and update the…

Photo by Fotis Fotopoulos on Unsplash

“In computer science, big O notation is used to classify algorithms according to how their run time or space requirements grow as the input size grows.” — Wikipedia.

In simple words, Big O notation theoretically explains how fast a piece of code is and how much memory it is using. Before we dive deep into Big O, we need to understand a couple of terms: time complexity and space complexity.

Time Complexity: Time complexity is the number of operations an algorithm/code requires to complete its task. The fewer operations it takes, the faster the algorithm is. By defining the N…

Muazzam Nashat

Full stack developer experienced in Ruby and JavaScript based programming.

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