Lodash.js – functions() function
A simple Lodash.js example of the functions() function, which iterates through the object and lists all the function names. It also enumerates inherited function names.
<!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');
function Utils() {
this.niceFunction = function() {
return "niceString";
}
this.addingFiveFunction = function(adder) {
return adder + 5;
}
this.decreasingThreeFunction = function(decreased) {
return decreased - 3;
}
}
Utils.prototype.multiplyByTen = function(multiply) {
return multiply * 10;
};
var utils = new Utils();
firstDiv.innerHTML = "Having an object with functions:<br><br>";
firstDiv.innerHTML += utils;
secondDiv.innerHTML = "...we will list all the functions inside of it... and we get:<br><br>";
var result = _.functions(utils);
secondDiv.innerHTML += JSON.stringify(result);
</script>
</body>
</html>