JavaScript: Find if the String Has a Particular Case

Helper methods to tell if the case of the string is camel, snake, kebab, upper, lower, or start.

Instead of writing our own logic to determine if the given string is of a particular case or not, we can write a helper method that acts as a wrapper, in which we compare the original string with the one returned by lodash method, and return true or false. The wrapper is a good way to pass on the responsibility of correct logic to lodash, a thoroughly tested library.

[Read More]

Replace All Keys of Deeply Nested Objects or Array of Objects in JavaScript

Change the case of object keys recursively to camel, snake, kebab, upper, lower, and start. Or modify in another way.

For a deeply nested object or array of objects, we might want to replace all the keys in some way, such as modifying their case (camel case, snake case, etc.) or adding an underscore at the start of each key or on both sides. Or we may like to change the keys in any other way.

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