We'll learn how to get a subset of an array by specifying items to include with filter, or items to exclude using reject. We'll also look at how to get the results from both filter and reject, neatly separated with partition.
Nicely done. What tools did you use to record this?
Mike, thanks for watching!
I'm using Atom with the Atom Material UI and syntax themes. The terminal is the term3 plugin for Atom, though I use iTerm for my terminal the majority of the time. I record the screen and do my editing with Screenflow and the audio is recorded with a supercardoid mic connected through a USB audio interface.
How could I extend this to filter global search style 1 character at a time to filter a nested array? The outer array are the parent rows displayed and the nested array is the expanded rows displayed under each parent. Is it possible to filter such an array?
I love the functional programming and this library in particular, don't misunderstand my comment.
If I'm wrong and the method has other benefits please let me know.
@pablo: The benefit is that now you can compose a specific filter operation and reuse it over and over with different data and even do so in a point-free way. I wrote an article on Ramda Chops: Map, Filter & Reduce, and this should help explain in detail. But for now:
const dogCheck = pet => pet.type === 'dog' const getName = prop('name') const onlyDogs = filter(dogCheck) const getDogsNames = compose(map(prop('name')), onlyDogs) getDogsNames([ /* one set of data */ ]) // some results getDogsNames([ /* another set of data */ ]) // some different results