Lodash.js – partialRight() function
A simple Lodash.js example of the partial() function, which invokes a function with partially appended arguments using placeholders.
<!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 welcome = function(welcoming, who) {
return welcoming + " " + who;
}
firstDiv.innerHTML = "Having a function which will be run with partially appended arguments using placeholders:<br><br>";
firstDiv.innerHTML += welcome;
var makeWelcome = _.partialRight(welcome, 'You are welcome', _);
var makeSecondWelcome = _.partialRight(welcome, _, ', you are welcome!');
secondDiv.innerHTML += makeWelcome('Bart!') + "<br>";
secondDiv.innerHTML += makeSecondWelcome('Bart');
</script>
</body>
</html>