E2EHIRING Logo
Jobs
Jobs
courses
Courses
mentorship
Mentorship
more
Moredropdown
E2EHIRING Logo
more
Jobs
Jobs
courses
Courses
mentorship
Mentorship
HomeSepratorIconBlogsSepratorIconJAVASCRIPT ARRAY METHODS (MAP, FILTER AND REDUCE FUNCTIONS)SepratorIcon

JAVASCRIPT ARRAY METHODS (MAP, FILTER AND REDUCE FUNCTIONS)

Han SoloAnbarasan Murugan
calendar27 Jun 2022
poster

MAP:


The map() method is used for creating a new array from an existing one, applying a function to each one of the elements of the first array.

Example;

const numbers=[1,2,3,4,5]
const results=numbers.map((x)=>{
return x;
});
console.log(results) ;//output [1,2,3,4,5]

FILTER:

The filter() method takes each element in an array and it applies a conditional statement against it. If this conditional returns true, the element gets pushed to the output array. If the condition returns false, the element does not get pushed to the output array.

Example;

const arr=[22,11,3,4,6]
const evens=arr.filter((x)=>{
return x%2===0;
});
 console.log(evens);//output even number[22,4,6]

REDUCE:

The reduce() method reduces an array of values down to just one value. To get the output value, it runs a reducer function on each element of the array.

 Example;

const numbers=[1,2,3,4]
const sum=numbers.reduce((result,item)=>{
return result+item;

},0);
console.log(sum);//output(10)

Recent Posts

Rapid Changes in the Coding World: Need for High Skilled Programmers e2eHiring Bridges this Gap with the Mentorship Program April 2023

Rapid Changes in the Coding World: Need for High Skilled Programmers e2eHiring Bridges this Gap with the Mentorship Program April 2023

How to publish your Android app on Google Play Store

How to publish your Android app on Google Play Store

Creating Dynamic User Interfaces with Android Motion Layout

Creating Dynamic User Interfaces with Android Motion Layout

Bean Life Cycle

Bean Life Cycle

Pom.XML

Pom.XML

copycopycopycopy

Han Solo

Recent Posts

Rapid Changes in the Coding World: Need for High Skilled Programmers e2eHiring Bridges this Gap with the Mentorship Program April 2023

Rapid Changes in the Coding World: Need for High Skilled Programmers e2eHiring Bridges this Gap with the Mentorship Program April 2023

How to publish your Android app on Google Play Store

How to publish your Android app on Google Play Store

Creating Dynamic User Interfaces with Android Motion Layout

Creating Dynamic User Interfaces with Android Motion Layout

Bean Life Cycle

Bean Life Cycle

Pom.XML

Pom.XML