Filtering, Mapping, and Reducing Arrays in Ionic 2
We often work with arrays of data in Ionic 2 applications – sometimes some data we have defined locally, sometimes data we may be loading in from some external source – and at some point, we may want to modify that data in some way. If you have an array of products, you may want to filter out results that don't meet certain criteria, you might want to modify that product data in some way, or you may want to perform some calculation on the data (like figuring out which product is the most expensive).
I've previously written an in-depth series on working with data in Ionic 2 applications here if you would like to read that. In this video tutorial, we will walk through a quick and practical example of applying filter, map, and reduce functions to a list of data in Ionic 2.
Here's the video:
filtermethod can be used to exclude elements from an array
mapmethod can be used to change data in the array
reducemethod can be used to reduce the elements in an array into a single value