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]

Shell Script to Delete and Recreate a Branch From Master

Both locally and remotely

To delete a branch and recreate it, both locally and remotely, here is a short shell script that asks for user confirmation and then proceeds to recreate the branch from master. In this example, the branch is development, the confirmation message is colored red to emphasize precuation, and the script only proceeds once user types exact yes.

[Read More]
git 

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 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]
When you purchase through links on techighness.com, I may earn an affiliate commission.