Skip to content

Instantly share code, notes, and snippets.

@Dosant
Last active February 25, 2017 17:26
Show Gist options
  • Save Dosant/980a96aa791664d48c505a8d84d25964 to your computer and use it in GitHub Desktop.
Save Dosant/980a96aa791664d48c505a8d84d25964 to your computer and use it in GitHub Desktop.
JS Bin// source https://jsbin.com/kuneyiq
function callAndLog(a, b, operation) {
console.log('Will call operation with params: ' + a + ', ' + b);
return operation(a,b);
}
function add(a,b) {
return a+b;
}
add(2,2); // 2;
callAndLog(3,3,add); // 9 (And logs message in console)
callAndLog(3,3, function(a,b) {
return a-b;
}); // 0 (And logs message in console)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment