
The React JS documentation emphasizes on using composition over inheritance for components, as there is hardly any scenario that requires component inheritance. However, that does not stop us from using inheritance and polymorphism within our JavaScript code. To explain, we discuss one such example below by using es6 classes:
[Read More]
Serialize and Deserialize JavaScript Class Objects In Front End Applications
The drawback of using JavaScript classes in your frontend application is that we cannot pass it to or receive it from the backend as class object. We need to serialize and deserialize it.
[Read More]JavaScript Get Information of Week Days Between Two Dates
With and Without Moment JS
Requirement: Given a start and end date, we need to find out which days of the week exist between them i.e. Sun, Mon, Tue, Wed, Thu, Fri, Sat (in numbers: 0, 1, 2, 3, 4, 5, 6). We might also want to count them, or we may only be interested if weekends exist.
[Read More]
What Are The Use Cases of Lodash Chunk method?
Chunk is a method of Lodash that splits the array into evenly sized arrays and returns them in a single array. If the array is indivisible evenly, the final chunk has the left over elements. It takes the size of the grouping in argument (the default size is 1).
[Read More]
JavaScript Flatten Deeply Nested Array of Objects Into Single Level Array
Using plain JavaScript, and lodash's flatMapDeep method.
Requirement: We have a deeply nested array of objects. We want to bring all the nested objects into the array at the root level.
Following is the example array familyTree that has multiple people in the root, and many of them have children array containing further members:
[Read More]
JavaScript Find Path of Key in Deeply Nested Object or Array
Key Path Finder Using Depth First Search (DFS)

The following two codes go through the whole object, an array of objects, or a collection of both to get the path to a particular key. There are two versions: first gets the path to the key only, and second gets the path where a key has the given value.
[Read More]JavaScript Check if Key Exists in Deeply Nested Object or Array of Objects, Without Knowing the Path
Depth First Search (DFS) for Key Verification in an Object
The following JavaScript code recursively goes through the whole object, an array of objects, or a collection of both to verify if the given key exists somewhere down the object. It does not require the path to the key in advance.
[Read More]How to Get All Uppercase Words From a String in JavaScript?
And All Lowercase Words, Too
On rare occasions, Google surprises you by returning no useful information for your search. Extracting numbers and retrieving all uppercase words from a given string in JavaScript were two such problems. In the latter case, there were all kinds of regex examples to find capitalized words or uppercase letters, but not the uppercase words.
[Read More]