JavaScript: Change The Behavior of A Class Method At Runtime

Useful Strategy To Perform Different Operations Without Repeated If Else Or Switch Statements

Recently I came across a problem where I needed to perform two different sets of operations throughout the application for two types of users. The trouble was:

  1. I needed to turn on or off an operation based on certain condition, which would only be known once the user was logged in, not at the beginning.
[Read More]

How To Publish And Use A Private JavaScript Library Without NPM Registry?

With The Help Of Github Repository And Version Tags

Node Package Manager, or NPM, is a defacto registry of JavaScript libraries, where anyone can create and publish a library (called package), both public and private. For publishing private packages, subscription fee is required.

In this post, we will discuss how we can host our public or private JavaScript library at Github, maintain various versions of the library using tags, and, finally, include a specific version of the library in some project and use its code.

[Read More]

What Is Destructuring And Restructuring Design Pattern In JavaScript?

A More Declarative Approach.

Two new features introduced in JavaScript es6 were destructuring and spread. Combining both, along with default function parameters, we can create and use a design pattern called Destructuring and Restructuring, that is more declarative than the usual implementation. This pattern and its name come from Kyle Simpson. [Read More]

React JS Code Review Checklist

A handy guide to review a pull request

This post provides a checklist to review a React JS application code. For many issues, especially related to personal taste like semicolon or arrow vs traditional function, and things like propTypes, we can simply configure linters such as ESlint and Prettier to automatically detect and force us resolve the warnings. We can furthermore make these linting fixes mandatory on commits (such as with Husky hooks) or PR merges (with CI/CD tools such as github Actions).

[Read More]