I have the following function, which itself contains a function.
var noisyFunction = function() {
return function() {
return "NOISY TOWN!"
}
}
Now, when I call noisyFunction by using
var theNoisy = noisyFunction()
the return function is what is returned.
Is there any way to just get "NOISY TOWN!" returned? I do not think the nested function can be specifically called. I feel like I am missing something.
Appreciate any direction that could be provided.
noisyFunction()()if you don't want an intermediate variable, however there is no way to just call the inner function without the outer one.noisyFunction()()call both the outer function and the inner function? Is that what is occurring?noisyFunction()is itself a function. Any value can be called as a function by appending()in the end. So, you just execute the result of the fist function. The same way you can doparseInt("40").toFixed("2")to call a number method on the result ofparseInt, since it returns a number.