Lodash.js – uniq() function
A simple Lodash.js example of the uniq() function, which creates an array of unique values from the first occurence.
<!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 = [2,2,2,1,1,1,1,2,1,2,1,2,3,3,1,2,2,2,2];
firstDiv.innerHTML = "Having the array: " + firstValue + " and using the lodash uniq function, we will create an array of unique values from first occurence...";
var result = _.uniq(firstValue);
secondDiv.innerHTML = "...so we get: " + result;
</script>
</body>
</html>