From the course: Learning Functional Programming with JavaScript ES6+
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Filtering - JavaScript Tutorial
From the course: Learning Functional Programming with JavaScript ES6+
Filtering
- [Instructor] The next important built-in array function is called Filter. Filter is used when you want to find all of the elements in an array that fit some kind of criteria. For example if we have an array of numbers and we want to get all the numbers from it that are even, or if we have an array of employee data, and want to find the employees from this array that make more than a certain amount per year. These are the things that Filter can help us with. The syntax to Filter is similar to Map. We can call it on any array and then we pass in a function. The main difference between Filter and Map is the type of function that we pass into it. In Map, we pass in a function that returns a value for each element in the array. And the return value of this function represents what the element becomes in our new array. On the other hand, for Filter, we pass it a function that returns either true or false for each element. If the function that we pass returns true for a given element, then…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
JavaScript: Functional parts1m 53s
-
(Locked)
The spread operator5m 30s
-
Mapping5m 11s
-
(Locked)
Filtering6m 59s
-
(Locked)
Every/some5m 46s
-
(Locked)
Slicing3m 38s
-
(Locked)
Sorting5m 11s
-
(Locked)
Reducing6m 23s
-
(Locked)
Combining functions6m 40s
-
(Locked)
Challenge: Recreate the map function1m 3s
-
(Locked)
Solution: Recreate the map function3m 6s
-
(Locked)
-
-
-