JavaScript Arrays: A Comprehensive Guide with Lodash Examples
Arrays in JavaScript are high-performacne, list-like objects. They use numeric indices starting from 0. This guide covers core array operations and common Lodash utilities for more advanced tasks.
Basic Array Characteristics and Operations
Array length: arr.length
Modifying length:
If you set a larger length, the extra slots become empty (not ...
Posted on Tue, 18 Aug 2026 16:27:57 +0000 by JJBlaha
JavaScript Operator Precedence and Index Traversal Logic in Utility Functions
Function Overview
The baseFindIndex utility serves as an internal helper similar to the ES6 Array.prototype.findIndex method. Its primary purpose is to locate the index of the first element that satisfies a provided testing function. Unlike the standard implementation, this utility supports traversal in both directions: forward from the start a ...
Posted on Wed, 08 Jul 2026 17:27:13 +0000 by MrXander
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