Lodash.js – uniqueId() function
A simple Lodash.js example of the uniqueId() function, generates a unique ID to a predefined prefix.
<!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 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 = 'item_';
firstDiv.innerHTML = "Having a prefix:<br><br>";
firstDiv.innerHTML += firstValue;
var result = _.uniqueId(firstValue);
secondDiv.innerHTML = "...we will get a unique ID... and we will finally get:<br><br>";
secondDiv.innerHTML += result;
</script>
</body>
</html>