I have a JavaScript function with unlimited arguments that also has an inside function that uses this arguments. Something like the function in this StackOveflow post which is
function StringCon(arg) {
var f = function(x) {
return StringCon(arg + x);
};
// var f = StringCon.bind(this, arg + x);
f.value = arg;
return f;
}
StringCon("I ")("am ")("new ")("to")(" JavaScript")
.value // -> "I am new to JavaScript"
I actually want to check where does this infinite currying ends. In the above example, I want to check when I get to the last call ("Javascript").
Actually I want to use this check in order to not use .value
. I actually want to use StringCon("I ")("am ")("new ")("to")(" JavaScript")
to get the "I am new to JavaScript" String itself, not a function which contains an attribute named value. So a I can actually use StringCon("HI)("HI") + StringCon("BYE")("BYE")
Is there any way to do this?