Actually, you still create an anonymous function expression and assign it to a local variable with scope f. Go for
function f( callback ) {
callback();
}
f( named_function );
function named_function() {
console.log('Sample callback function!');
}
Thus, you even avoid memory leak of the named function name in <= IE8, plus, since you no longer create a function expression, but a function declaration *, you can even access the finside of the body.
jAndy source
share