React developers should be familiar with certain JavaScript code patterns. Once you understand these patterns, it is easy to review code written by other developers, review blog posts or StackOverflow answers. Let us get going.

1. Class with constructor

ES2015 introduces class keyword. Most developers use class with constructors to initialise object properties. We use state as an object property within a React component.…

Read More

Consider an empty object. Print the object using toString method.

const obj = {};
console.log(obj.toString()); // [object Object]

We get the result [object Object] in the console. How does it work? (Interview question). Developers who have a strong background in C++ or C# will blindly attribute it to OOPs. All objects inherit from Object.

JavaScript is to Java what Cartoon is to Car.

Read More

Cross cutting concerns (wiki) are common architectural elements such as logging, instrumentation, caching and transactions. In this article, we will explain how we integrate these into our projects. The functional classes in our project may use logging or caching within their method. Or they may not know that these other classes exist. We will cover both scenarios.

Decorator pattern

Decorator pattern is an elegant solution to implement cross-cutting concerns.…

Read More