[Javascript] defining functions before they're called

Troy III Ajnej trojani2000 at hotmail.com
Sun Aug 23 17:34:24 CDT 2009


Hi Paul

It is true that you can point to the function variable name before 

the actual function is created, because you can decide on the name 

of your child months before its actually borned. There's nothing wrong

with it. 

 

It's only a reserved name for some function; therefore, there should 

be no error. Since the name is in fact a pointer and will gain its meaning

only after the moment that the planned kid come to life.

 

But this:

showme();  
var showme = function(){alert('hi');}

 

...won't work! (since it's not a predefined empty Function Object, but

a variable that will require its exact value while being read)

 

About following issue:

> 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!).


In fact you can force the browser to use any JavaScript version you

like so you won't have to go looking for IE3.11 out there!

 

This will do the trick:

 

<script language="javascript">

showme(); 

  function showme(){ alert('hi') }

</script>

 

That would mean: "Javascript v1.0". 

Higher versions will require version numbers. But no harm if you

try them both ('javascript" and "javascript1.0").

 

You can also run these tests, (just for fun and curiosity):

 

<script language="javascript">
      showme();
      function showme(){alert('hi from javascript 1.0')}
</script>
  
<script language="javascript1.3">
      showme();
      function showme(){alert('hi from javascript 1.3')}
</script>

 

<script language="javascript1.8">
      showme();
      function showme(){alert('hi from javascript 1.8')}
</script>

 

<script language="javascript7.8">
      showme();
      function showme(){alert('hi from javascript 7.8\nthis is Opera and it is lying!')}
</script> 


The latest really supported JS by Opera is 1.5.

 

Well W3C spoiled this capability and compatibility too.

 

Regards. 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                      Troy III
                         progressive art enterprise
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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


_________________________________________________________________
Get back to school stuff for them and cashback for you.
http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1


More information about the Javascript mailing list