I want to organize my JavaScript so I thought I would make a functions JS file. Is there anyway I can call the functions from functions.js from global.js?
EDIT
functions.js:
var get_selects;
get_selects = {
getLanguages: function() {
}
}
global.js:
get_selects.getLangueges();
Yes, functions defined at the top level are automatically available in the global scope (
windowin a browser), and this is typically not desirable.Another approach that would mitigate this is to group your functions into a single object so you aren’t polluting the global scope with a whole bunch of unrelated functions.