Defining Functions

<SCRIPT>

function1();

function function1() {
     alert("This is function1 running.");
}

</SCRIPT>

You saw an alert(...) created by function1(). However, you notice that the function call appears before the function definition -- it appears that we have used the function before we created it. It has been stated before that you have to define something before you can call "it" or use "it".  

The reason we don't get an error message here is because JavaScript first puts everything between the <SCRIPT> tags into memory and then it proceeds to process everything within the <SCRIPT> tags line by line. Now when function1() gets called it "already exists".