In this tutorial, you will learn some essential methods you need in order to master Javascript.  Getting data from an API and displaying it on a webpage, is web development 101 these days.  There are multiple ways you can write code to do this, some better than others.

The Javascript Dream Way Of Writing Code

When dealing with Javascript collections, you want to aim to write declarative code and in an ideal world should be aiming to write pure functions, e.g. you do not want to mutate/change your collections. Here are 10 javascript array methods you should at least know, starting with .forEach();

includes()

This method can help you to loop over the array's items.

This method checks if the array includes the item passed in the method.

filter()

This method creates a new array with only elements passed condition inside the provided function.

map()

This method creates a new array by calling the provided function in every element.

reduce()

The reduce() method applies a function against an accumulator and each element in the array (from left to right) to reduce it to a single value - MDN

some()

This method checks if at least one of the array’s items matches the condition. If so, it returns ‘true’ otherwise ‘false’.

every()

This method checks if all items within the array met the criteria. If passed, it returns ‘true’ otherwise ‘false’.

sort()

This method used to arrange/sort the arrays items in either ascending or descending order.

Array.from()

This changes all things that are array-like or iterable into true array especially when working with DOM, so that you can use other array methods like .reduce(), map(), filter() and so on.

Working with the DOM

Array.of()

This creates an array from every argument passed into it.