Edit: I want to better understand how internal functions 'take' the additional arguments passed to a function. (E.g. the function requires one argument and we give it three. Where do the other two go?). For the sake of this question, I want to avoid using the arguments object.
I am hoping to gain a better understanding of how optional arguments 'fall through' to internal functions. I'll use the code below as an example:
function outside() {
var x = 10;
function inside(x) {
return x;
}
function inside2(a) {
return a;
}
return inside2; // or inside, doesn't seem to make a difference here
}
outside()(20,5)
Regardless of whether outside() returns inside2 or inside1, the number 20 is always returned. Is there any way to utilize additional inputs for the other internal functions?
For example, something like this (invalid code):
function outside() {
var x = 10;
function inside(x) {
return x;
}
function inside2(a) {
return inside();
}
return inside2;
}
outside()(20,5)