Created
February 9, 2017 04:58
-
-
Save wichopy/b421662e5dfad4b0511b8c43bca60827 to your computer and use it in GitHub Desktop.
wraplog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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