Lodash.js – unzipWith() function

A simple Lodash.js example of the unzipWith() function, which creates an array of ungrouped elements by category and invokes an operation on it in the second parameter.
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="Tizen Angular.js example"/>
    <title>Tizen lodash.js example</title>
    <script src="js/lodash.min.js"></script>
</head>
<body>
<div id="first">
</div>
<br>
<div id="second">
</div>

<script>

    var firstDiv = document.getElementById('first');
    var secondDiv = document.getElementById('second');

    var firstValue = [[12, 42, 56], [23, 24, 345], [213, 31, 45]];

  firstDiv.innerHTML = "Having the arrays: " + firstValue[0] + " and " + firstValue[1]  + " and " + firstValue[2]  + " and using the lodash unzipWith function, we will create an array of ungrouped elements by category and invoke an operation in it in the second parameter...";

    var result = _.unzipWith(firstValue, _.add);

  secondDiv.innerHTML = "...so we get 3 arrays of grouped values and performed a lodash _.add operation: <br><br>" + result[0] + "<br>" + result[1] + "<br>" + result[2];

</script>
</body>

</html>

Responses

0 Replies