I’m trying to call a function from inside the call of another function.
If I do it like this, it works fine. This returns ‘x’:
function returnval() {
return ("x");
}
alert(
returnval();
)
But how can I do the same thing while declaring the returnval function inside the function call? I’ve tried this, and everything else I could think of, to no avail. It returns ‘function(){return(“x”);})’ instead of the value itself, ‘x’:
alert(
function() {
return ("x");
}
)
In a similar vein, I’d like to include if-statements in function calls as well. Is this at all possible?
Any help would be appreciated. 🙂
There’s a thing, called like instant function call. You call a function just after a declaration:
upd here it is: http://www.jspatterns.com/self-executing-functions/