module - Static import in JavaScript -



module - Static import in JavaScript -

if have module public fellow member , utilize this

module.sub.member()

then best (if exists) way static import fellow member local scope, using in cpp or import static in java?

var app = (function(app) { /* dependencies */ var sound = app.modules.sound, input = app.modules.io.input, ... /* actual code using dependecies */ ... })(app || {});

this solution has several advantages:

stated @ top of module, it's visible @ first glimpse (maintainable code) ,

usual benefits of imports: less typing, avoidance of namespace clashes etc. (maintainable code)

long property path look-ups (a.b.c.d) needed 1 time (performance) ,

using local variable faster, using global variable - quicker look-ups (performance),

minification tools can minify local variable names safely, can't trivially minify global variables.

javascript module

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -