Crafting a Generic Filter Function

Build a generic filter function with TypeScript.

It’s time to create the final generic functionality in this course—generic filtering. Filtering is like searching in that we’ll utilize JavaScript’s built-in filter function, but our predicate function will be more complex.

Filtering vs. Searching and Sorting

In some ways, filtering isn’t as intuitive as search or sort. For example, let’s consider a property that is of type string. There are numerous edge cases we have to consider. For example, what do we do with properties that have any empty string value, like ""? What do we do if the value is null? What if it’s undefined? There are a few options available to us. We could remove these empty null and undefined values entirely or perhaps ...