Lodash.js – zip() function
A simple Lodash.js example of the zip() function, which creates an array of grouped elements consisiting of the given arrays and in the given order.
<!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 = ['Tony', 'Andrew', 'Bart'];
var secondValue = [42,19,31];
var thirdValue = ['passed', 'failed', 'passed'];
firstDiv.innerHTML = "Having the arrays: " + firstValue + " and " + secondValue + " and " + thirdValue + " and using the lodash zip function, we will create an array of grouped elements consisiting of the given arrays and in the given order...";
var result = _.zip(firstValue, secondValue, thirdValue);
secondDiv.innerHTML = "...so we get 3 arrays: <br><br>" + result[0] + "<br>" + result[1] + "<br>" + result[2];
</script>
</body>
</html>