Last active
November 27, 2017 12:54
-
-
Save giscafer/ebbdf8c15f649e907e0c7fbe9ef9c970 to your computer and use it in GitHub Desktop.
fedemo.duapp.com.ts
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 currying = function(fn) { | |
var _weight = 0; | |
var _args = []; | |
return function() { | |
if (!arguments.length) { | |
return fn.apply(this, _args); | |
} else { | |
Array.prototype.push.apply(_args, arguments); | |
return arguments.callee; | |
} | |
}; | |
}; | |
var weight = 0; | |
var addWeight = currying(function() { | |
var len = arguments.length; | |
for (var i = 0; i < len; i++) { | |
weight += arguments[i]; | |
} | |
}); | |
addWeight(1)(2)(3)(4)(); | |
console.log(weight); |
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
// https://fedemo.duapp.com | |
console.log('https://fedemo.duapp.com') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment