JavaScript Array Methods Cheat Sheet 2025 (Complete Reference)
JavaScript arrays have over 30 built-in methods. Knowing which one to reach for — and understanding the subtle differences between similar methods — is what separates junior developers from experie...

Source: DEV Community
JavaScript arrays have over 30 built-in methods. Knowing which one to reach for — and understanding the subtle differences between similar methods — is what separates junior developers from experienced ones. This cheat sheet covers every important array method with practical examples, organized by use case. Transformation map(callback) → new array Transform each element into something else. Never mutates the original. const prices = [10, 20, 30]; // Basic transformation const doubled = prices.map(p => p * 2); // [20, 40, 60] // Transform objects const users = [ { id: 1, firstName: 'Alice', lastName: 'Smith' }, { id: 2, firstName: 'Bob', lastName: 'Jones' }, ]; const fullNames = users.map(u => `${u.firstName} ${u.lastName}`); // ['Alice Smith', 'Bob Jones'] // Extract a field (use for select/pluck) const ids = users.map(u => u.id); // [1, 2] // Map with index const indexed = ['a', 'b', 'c'].map((item, i) => ({ index: i, value: item })); // [{index: 0, value: 'a'}, ...] flatM