![]() |
VOOZH | about |
The zip() function is used to combine the values of given array with the values of original collection at a given index. In JavaScript, the array is first converted to a collection and then the function is applied to the collection.
Syntax:
data.zip(value)
Parameters: This function accept a single parameter as mentioned above and described below:
Return value : Return a new collection by margin the value with the main collection one by one.
Below examples illustrate the zip() function in collect.js:
Example 1: Here in this example, we take a collection and then using the zip() function we matched them with a array of corresponding items of a new collection using the zip() method
Output:
[ Collection { items: [ 'Apple', 10 ] },
Collection { items: [ 'Banana', 15 ] } ]
Example 2:
Output:
[ Collection { items: [ 'Ram', 20 ] },
Collection { items: [ 'Sham', 25 ] } ]
Reference: https://collect.js.org/api/zip.html