Image credit to Any IP Ltd
Array map () will create a new array that a result from manipulating the original array. This method is powerful as in my imagination it’s working as for Each () in simpler and more compact syntax.
This is an example:
If you need a new array that only contains email address only from the data, you can map () the array:
The map () method is handy too if you think you need to manipulate the data a bit (adding new property) before further process. Let say you need 1 new property “location” that indicates all “Senior Developer” are from “Bali” and others are from “Sydney”. You can write your map () something like this:
find () method will return the first element that is found in the Array. This method, as the name says it, is helpful for us to find the element, based on the criteria you have set, in the Array.
filter() will return a new array, based onthe search criteria that is set. So it can be an empty or filled array.
PUTTING THEM ALL TOGETHER
This section will show you how we use the sample above in a vue.js project. I have 1 page, About Us page, that shows the list of personnels with a filter search form. The search/filter in this example is only found in the “name” field only.
The page will look like this: