Skip to content

Instantly share code, notes, and snippets.

@fedyk
Created September 7, 2016 11: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 fedyk/429027fa31416ef65df302867e7a1687 to your computer and use it in GitHub Desktop.
Save fedyk/429027fa31416ef65df302867e7a1687 to your computer and use it in GitHub Desktop.
bob(1)(2)(3)(4)...(n) + '' == 1 + 2 + 3 + 4 + ... + n
function bob(val) {
if (this === window) {
return (new bob(val)).factorInc();
}
else {
this.v = val;
}
}
bob.prototype.inc = function(v) {
this.v += v;
return this.factorInc();
}
bob.prototype.toString = function() {
return this.v;
}
bob.prototype.factorInc = function() {
var inc = this.inc.bind(this);
inc.toString = this.toString.bind(this);
return inc;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment