Is there any practical difference between using an IIFE versus calling a "main" function?
It seems the trend lately is to wrap code in a
(function() {...})();
construct where possible, where in the past a
main();
function main(){...}
construct was more common.
Is there any practical difference? Do both equally preserve global namespace?
The latter easily allows for an initial condition check, like
if (app.documents.length > 0 && app.selection.length > 0) {
main(app.selection[0]);
}
Is there any performance difference in just performing that check inside the IIFE?
Sorry if these have obvious answers. I'm starting to rely more and more on scripting to improve workflow, and would like to move the bar to writing better code, rather than just functional enough to get by.
