The Array object is used to store multiple values in a single variable
- filter(): Use to filtered out the items from an array.
- map(): Return a new array with the results of calling a function for every array element.
- find(): Return array element where the function returns a true value.
- forEach(): Method calls a function once for each element in an array.
- some(): Return true if any of the elements in an array pass a test.
- every(): Return true if all elements in an array pass a test.
- reduce(): Apply some operation on an array and return the combination of all those operations.
- includes(): Determines whether an array contains a specified element.
The filter() method return a new array from a given array consisting of only those elements from the given array, which satisfy a condition set by the argument method. Below is the Example.
The map() method return a new array by calling a specific function on each element present in the parent array.
Keep in mind that the resulting array will always be the same length as the original array. Below is the Example.
The find() method return the first element or object match in the array that satisfies the provided condition.
Keep in mind that it will return the only first match and skip the all other match.
The forEach() method is just unlike with other methods does not return anything its work similar to For Loop but it has a parameter. So in this loop, we just print out what we want.
The some() method tests whether at least one element in the array passes the test implemented by the provided function. It returns a Boolean value.
Validates against every element and return true if at least one of the element is validated as true.
The every() method tests whether all elements in the array pass the test implemented by the provided function. It returns a Boolean value.
Validates against every element and return true if all the elements are validated as true.
The includes() method is used to know either a particular element is present in the array or not and accordingly, it returns true or false i.e, if the element is present, then it returns true otherwise false.