Well, you could use arguments.callee to call it, but it's a bad idea, a performance hit, and it isn't valid in strict mode.
What you've quoted is valid JavaScript and should not make check call another check function if you have one alongside it. Sadly, though, it will in IE8 and earlier because they quite incorrectly leak the name check to the surrounding scope (named function expressions do not add the function name to the surrounding scope like function declarations do — except on IE8 and earlier [and that's not all they get wrong with them]).
So the solution is to use an anonymous function to hide a named one:
(function() {
// A check function
check();
function check () {
if (typeof foo !='undefined') {
// do stuff
} else {
console.log("Failed to load, trying again");
setTimeout(function(){ check(); }, 10);
}
}
})();
(function() {
// A complete different one
check();
function check () {
if (typeof foo !='undefined') {
// do other stuff
} else {
console.log("Failed to load, trying again");
setTimeout(function(){ check(); }, 10);
}
}
})();
they end up calling each otherExample please