My First JavaScript Functions...

<HTML>
  <SCRIPT>

  function MyFirst ( )
   {
     alert("This is from my first function.");
   }

</SCRIPT>
</HTML>

Mmmm, let's see now...

Calling Functions...

You can write as many different kinds of functions as you choose in JavaScript.  However to make a function do its task it must be called.

Calling a function forces the function to execute the code between the opening and closing braces
{  }.

I tried that function and nothing happened.

Program Structure...

  The above JavaScript program could have been entered in your text editor as shown below and still "work" correctly - Your browser would not care.

<HTML><SCRIPT>
MyFirst( );function MyFirst ( ){alert("This is from my first function.");}
</SCRIPT></HTML>

  However, the above code is difficult to read and understand.  Just as we use structures of sentences and paragraphs to make it easier for us to read material, structure applied to any programming language makes it easier to understand what the program is attempting to do.

  Good programming structure also makes it easier for us to correct programming errors or make improvements or other modifications..

Copyright © 2000 Adamson House, Ltd.