| Refresh | Home EGTry.com

execution sequence -- use functions which are defined later


commentsJavascript sourceExecution result in your current browser
define a function, then use it
   function f1() {
    document.write("f1 is called");
   }
   f1();

use a function, then define it
   function f2() {
    document.write("f2 is called");
   }
   f2();

define a function in this script block
     function f3() {
      document.write("f3 is called");
     }

use the function defined in earlier block
       f3();

ERROR: can not call a function which is going to defined in later separate block
      f4();

define f4
        function f4() {
          document.write("f4 is called");
        }