Skip to content

Instantly share code, notes, and snippets.

@olegakbarov
Last active August 29, 2015 14:19
Show Gist options
  • Save olegakbarov/78cb289c4c938d13bf7e to your computer and use it in GitHub Desktop.
Save olegakbarov/78cb289c4c938d13bf7e to your computer and use it in GitHub Desktop.
// наивная реализация выглядит вот так:
function Inherit(object, parent) {
for (var key in parent) {
object[key] = parent[key]
}
}
/*
для любого sum(1)(2)(3)...(n) == m
*/
function sum (a) {
var res = function (b) {
return sum (a + b);
};
res.valueOf = res.toString = function () {
return a;
};
return res;
}
console.log(+sum(1)(2)(3)(4)(5)(10));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment