Skip to main content

Command Palette

Search for a command to run...

Javascript Higher Array Methods

Published
•1 min read•View as Markdown
B

Web Developer skilled in HTML, CSS, JavaScript, NodeJS, Bootstrap, ExpressJS, EJS, and MongoDB.

Looping through an array has its perks, depending on what we want to achieve or do. There are a lot of different array methods with each of them having its specific purpose.

I'll be going through 5 different array methods and their uses.

ForEach()

This method executes a provided function for each element in an array. It is a better way to loop through an array than for loop.

Map()

This method creates a new array. Instead of filtering elements out, map creates a new array.

Filter()

It helps filter things from an array. It returns a new array with all elements that pass the test defined by the given function.

Sort()

This method sorts the items in an array in a specific order either ascending or descending.

Reduce()

It works by executing a reducer function on each element of an array and returning a single value.

I hope this helps you to understand the array methods mentioned better. Thanks for reading.