Crafting a Generic Search Function
Learn how to build a generic search function in TypeScript.
Now that our application successfully displays our widgets
and people
objects, we can start building our first functionality, a generic search function that we’ll call genericSearch
.
What is search, really?
In its most abstract form, searching is finding data that matches a query. In our situation, because we have already decided to map
over both the widgets
and people
variables, we could consider our search to just be the call to the JavaScript array filter
function before we call map
to render the items. With our current setup, that looks something like this:
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy