[Javascript] defining functions before they're called

Paul Novitski paul at juniperwebcraft.com
Thu Aug 20 13:05:24 CDT 2009


Can you think of a reason why one shouldn't call a function before 
it's declared in the source code? For example:

         window.onload = initialize;

         function initialize()
         {
                 ...
         }

I can certainly understand why one might choose, stylistically, to 
always define functions before calling them. However, I have never 
experienced any problem using JavaScript by putting the call before 
the function being called. It's my personal preference to put the 
call first because I like to read scripts top-down, seeing how a 
function is used before reading the details of exactly what the 
function does. But I'm curious to know if any of you has ever 
encountered a problem doing so.

Regards,

Paul
__________________________

Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com 




More information about the Javascript mailing list