Skip to content

Instantly share code, notes, and snippets.

@giscafer
Last active November 27, 2017 12:54
Show Gist options
  • Save giscafer/ebbdf8c15f649e907e0c7fbe9ef9c970 to your computer and use it in GitHub Desktop.
Save giscafer/ebbdf8c15f649e907e0c7fbe9ef9c970 to your computer and use it in GitHub Desktop.
fedemo.duapp.com.ts
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);
// 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