How do you call the callback in javascript when it is named (directly in the statement)?
Example:
Common declaration of a function:
function fn()
{
console.log(fn); // Imprime fn()
return 'do';
}
fn(); // 'do
Declaration (I do not know if that's what it's called) at the same time that we go through callback:
call(function fn()
{
console.log(fn); // Imprime: fn()
});
fn(); // Erro: função não foi definida
Another example:
$('element').on('action', function fn()
{
if ($(this).next().size()) {
fn.call(this);
}
});
console.log(fn)// Erro: Função não definida
-
What is the difference of this naming function?
-
One is a statement and the other is an expression?
-
This can be called an anonymous function (since it has a name, even if it's just for that scope)?