
JavaScript Array Methods Cheat Sheet: map, filter, reduce, and More
JavaScript arrays come with a rich set of built-in methods that cover nearly every data-manipulation need. Instead of reaching for a utility library, master these native methods and your code stays lean and readable. This cheat sheet covers every essential array method with a one-sentence description and a practical example. Transformation Methods map Returns a new array where each element is the result of calling the callback. const prices = [ 10 , 20 , 30 ]; const withTax = prices . map ( p => p * 1.08 ); // [10.8, 21.6, 32.4] filter Returns a new array containing only elements where the callback returns true . const scores = [ 45 , 72 , 88 , 33 , 95 ]; const passing = scores . filter ( s => s >= 60 ); // [72, 88, 95] reduce Reduces the array to a single value by accumulating results through the callback. const cart = [{ price : 12 }, { price : 8 }, { price : 25 }]; const total = cart . reduce (( sum , item ) => sum + item . price , 0 ); // 45 Always supply the initial value (second
Continue reading on Dev.to Tutorial
Opens in a new tab



