Skip to content

Instantly share code, notes, and snippets.

@wichopy
Created February 9, 2017 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wichopy/b421662e5dfad4b0511b8c43bca60827 to your computer and use it in GitHub Desktop.
Save wichopy/b421662e5dfad4b0511b8c43bca60827 to your computer and use it in GitHub Desktop.
wraplog
var wrapLog = function (callback, name) {
//var args = callback.apply(null,arguments);
//console.log(arguments);
//console.log(args);
//console.log(arguments[0]);
//console.log(arguments);
return function() {
//console.log(arguments);
//console.log(callback.apply(null,arguments));
//var arg2 = 1, arg1 = 2;
console.log(name+"("+arguments[0]+","+arguments[1]+") => "+callback.apply(this,arguments));
};
};
var sum = function (a,b) { return a + b; };
var logSum = wrapLog(sum, "sum");
logSum(5,3); // sum(5,3) => 8
logSum(3,2); // sum(3,2) => 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment