Understanding Array Iteration Choices in Lodash's compact Implementation

The compact functon in Lodash filters out falsy values (false, null, 0, "", undefined, NaN) from an array and returns a new array containing only truthy elements. Its implementation is minimal yet deliberate—especially in how it iterates. Core Implementation Here's a refactored version of the logic, preserving correctness while renami ...

Posted on Tue, 19 May 2026 18:35:20 +0000 by michaeru

Common Lodash Functions and Their Native JavaScript Alternatives

Iterating a Specific Number of Times JavaScript's for loop is standard for iteration, but Lodash's _.times offers a concise alternative for fixed counts. // Native JavaScript for (let i = 0; i < 5; i++) { console.log(i); } // Lodash _.times(5, (index) => { console.log(index); }); Accessing Nested Porperties Lodash's _.map allows ...

Posted on Sun, 17 May 2026 18:52:06 +0000 by zander213