Filtering, Mapping, and Reducing Arrays in Ionic 2

Filtering, Mapping, and Reducing Arrays in Ionic 2

Follow Josh Morony on

Learn Ionic with Josh ☕

Hey, I hope you enjoy the article.

If you want a weekly update with my newest content, access to the blog's bonus content, or you want to sign up for one of my free beginner or advanced email courses just enter your details here or in the form below.

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

If you enjoyed this article, feel free to share it with your friends ☝

Check out my latest videos: