Collect.js | transform() Function
Parameters: This function accepts two parameter as mentioned above and described below:
- item: This parameter holds the collection item.
- key: This parameter holds new operational value.
Return Value: Returns an modified array which is created by this function.
Below examples illustrate the transform() function in collect.js
Example 1: Here in this example, we take a collection and then using the transform() function modified the values using the key transformation parameter and return the new value.
[5 , 10 , 15 , 20 , 25 ]
Example 2: Same thing we have done here as above example.
[1 , 2 , 3 , 4 , 5 ]