[Javascript] defining functions before they're called

Paul Novitski paul at juniperwebcraft.com
Thu Aug 20 17:18:18 CDT 2009


At 8/20/2009 01:58 PM, I wrote:
>          showme();
>
>          function showme()
>          {
>                  alert('hi');
>          }


To follow up, I've successfully tested this example of calling a 
function before it's declared in these Windows browsers:

         Firefox 3.5
         IE 8
         IE 7
         IE 6
         IE 5.5
         IE 4.01
         Opera 9.6.4
         Safari 4.0.3

I don't have a functional copy of IE 3 (which used JavaScript 1.0) so 
I can't test it on this. IE 4 (copyright 1995-97) contains JavaScript 
1.2 (which, aside, is close to the level Microsoft supports today!).

I'd be willing to bet a big fat nickel that any browser functioning 
today will execute this example script. If I'm right, where's the 
rationale for the declare-before-you-call scripting style? I think it 
has nothing to do with JavaScript functionality and has arisen 
because function source order matters or once mattered in other 
and/or older programming languages and has been erroneously 
superimposed on JavaScript usage.

Regards,

Paul
__________________________

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




More information about the Javascript mailing list