Do javascript functions need to be declared in the reverse order? -


elaboration: if have, example following code:

//javascript example var alice = function() {     var value = bob() + 1;     console.log value } var bob = function() {     var value = 1;     return value; }  //running function alice() 

would have declare function b first, because calling in function without reaching function b yet.

no.

if have function declaration, hoisted , order doesn't matter (although putting functions in order function call doesn't appear before function being called practice).

if have function expressions (as in example), need have functions created before called, noting in example none of them called before line alice() line needs after functions , order of functions doesn't matter. (but best practise principles described above hold).


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -