List iteration is performed using the Array.forEach() method to loop through list items. Kyle spends a few minutes discussing the list iteration implementation and explains this difference between using forEach() and map().
- List iteration, I have the exclamation marks here…because I want to remind you, that even though…this is one of those helpers and it oftentimes…gets lumped in with the other functional programming things,…most people say don't do this one.…And you'll see very quickly why.…If I made an iterate function,…like for example I wanted to take my array…and log out all the values in the array.…Cause you notice I'm not actually performing an operation…on the list to change something,…I'm just performing an operation with the value of the list.…But what's the only way that doing that would mean anything?…Is if my predicate had a side effect right.…
Some side effect, whether it's a console.log,…or changing it in the original array,…like an in-place change, or something like that.…The only reason that a list iteration would make any sense…and do anything useful to us at all…is if the predicate had a side effect.…Well you can probably spot why that's not the favorite tool…in a functional programmer's bag.…So most functional programmers will tell you,…
This course was created by Frontend Masters. It was originally released on 03/08/2016. We're pleased to host this training in our library.
- Pure functions
- Manual composition
- Composition utility
- List operations
Skill Level Intermediate
1. Pure Functions
2. Composition and Immutability
3. Closure and Recursion
4. List Operations
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.