Prerequisite — You will need to have a basic knowledge of CSS Selectors.

If there are two or more conflicting CSS rules that target the same DOM element, the browser follows some rules to determine which one is more specific and therefore wins out (gets applied).

Conflicting CSS Sample

In the above code snippet, we have two CSS rules pointing to the same div. But in this case, due to higher specificity (we will discuss in detail what this means below), the 2nd CSS rule wins and background color of the div becomes green.

Let’s now have a look at how to calculate…

Prerequisite — JavaScript Event Loop. If you do not know how JavaScript handles asynchronous tasks, please read my article JavaScript Event Loop Explained before proceeding.

In simple words, Promises are another way to handle asynchronously running tasks in Javascript. It gives us handles (callback functions) which we attach with the asynchronous action’s eventual success (with a result) or failure (with a reason)

Basic Promise structure

Long answer

Lets progressively build a Promise to understand its different parts

The asynchronous task we are going to be using is, to respond with the message ‘Successful’ if Math.random() returns a value greater than 0.5 …

“How is JavaScript asynchronous and single-threaded ?” The short answer is that JavaScript language is single-threaded and the asynchronous behaviour is not part of the JavaScript language itself, rather they are built on top of the core JavaScript language in the browser (or the programming environment) and accessed through the browser APIs.

Now for the long answer, let me try through 2 sample code snippets.

Basic Architecture

Overview of major components in a browser
  • Heap - Objects are allocated in a heap which is just a name to denote a large mostly unstructured region of memory
  • Stack - This represents the single thread provided for JavaScript code execution. …

Middleware is the suggested way to extend Redux with custom functionality. The most common use case for middleware is to support asynchronous actions without much boilerplate code or a dependency on any library.

We will be concentrating more on the inner workings of applyMiddleware function

Before we dive into, we need to take a look at 2 topics: currying and composing of functions :

Currying of Functions

Currying is the way of constructing functions that allows you to

  1. pass all the arguments a function is expecting and get the result or
  2. pass a subset of those arguments and get back a function that’s…

JavaScript Dev with an affinity to React.

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