Created
September 7, 2016 11:58
-
-
Save fedyk/429027fa31416ef65df302867e7a1687 to your computer and use it in GitHub Desktop.
bob(1)(2)(3)(4)...(n) + '' == 1 + 2 + 3 + 4 + ... + n
This file contains hidden or 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
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