I am trying differents methods to implement a function, but one o them isn't working. Are this syntax correct?:
function funcao2()
{
alert('Tudo bem?');
}funcao2();
I have a 'self invoking function', an 'anonymous function' and a 'function attributed to a variable', but the second aren't working. See the code:
//Função de auto-invocação anônima ou função recursiva anônima
(function(){
alert('Oi');
})();
//Função anônima
document.onload = function(){
alert('Página carregada');
};
//Atribuir função a uma variável e executá-la em seguida
var funcao = function(){
alert('Oi novamente');
}; funcao();
document.onloadshould bewindow.onload,documenthas theonreadystatechangeevent, thewindowloads;) is optional, but in the last case (fucao) it's preferable to separate the function definition and the actual call with a semi-colon.