javascript - Meteor js - Function declaration vs Function expression in another file -


in meteor js:

// in: server/lib/utils.js     function foo() {         return 'bad'     }      bar = function() {         return 'good'     }      // in: server/server.js     part(of(a(larger(computation(foo())))))     bar() 

calling foo results in runtime error: foo not defined.

calling bar not.

why? also, there better way group functions rather having file bunch of function expressions bounded global variables?

thats because when declare bar = function(){} making global scoope function, , thats why can access whatever server js file.

and function foo(){} not global function.