Tutorial hero
Lesson icon

Filtering, Mapping, and Reducing Arrays in Ionic 2

Originally published December 07, 2016 Time 2 mins

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:

Video Notes

  • The filter method can be used to exclude elements from an array

  • The map method can be used to change data in the array

  • The reduce method can be used to reduce the elements in an array into a single value

  • These methods are not unique to Ionic 2, it is just plain Javascript

Learn to build modern Angular apps with my course