Subj : Re: Calling a function before it's declared To : netscape.public.mozilla.jseng From : Brook Monroe Date : Wed Nov 24 2004 11:47 am Martin Honnen wrote: > > > Brook Monroe wrote: > > >> Declaration order isn't critical. Calling functions that haven't been >> defined yet will work because the call resolution occurs at run-time, >> not compile time. > > > You can call a function before its declaration as program execution is > defined to be a two pass execution where the first pass goes through the > program and executes all function declarations and then the second pass > executes the global statements (e.g function calls) in source order. > Same difference. Although that doesn't answer the question of why JS_CompileFile() (which, according to that explanation, would "execute" the function declarations) doesn't allow direct function calls through JS_CallFunctionName() without going through JS_EvaluateScript() first. .