To use the unzipWith
function from the Lodash library in TypeScript, you first need to install the package using the following command:
index.ts26 chars2 lines
After that, you can import the unzipWith
function from the lodash
package in your TypeScript file as follows:
index.ts224 chars9 lines
In the above example, we have created a zipped
array with two sub-arrays containing string and number values. We passed this array as the first argument to the unzipWith
function along with a custom function as the second argument. The custom function takes each sub-array as an argument, and we have used the reduce
function to sum up the values in each sub-array. Finally, we log the result to the console.
The unzipWith
function returns a new array with unziped values after applying the custom function to each array.
gistlibby LogSnag