Managing namespaces in JavaScript presents its own challenge, since the language’s default behavior is to start slapping things into window
. For this reason, people have built a number of libraries and practices to solve this problem.
Jared’s company, for example, uses RequireJS
to load dependencies, like the lodash
utility-belt library. Sadly for Jared, their new hire proved that all the module-loading libraries in the world don’t solve incompetence.
if (_) {
if (__) {
if (___) {
if (____) {
if (_____) {
if (______) {
if (_______) {
if (________) {
if (_________) {
if (__________) {
if (___________) {
if (____________) {
if (_____________) {
if (______________) {
if (_______________) {
if (________________) {
if (_________________) {
if (__________________) {
if (___________________) {
if (____________________) {
if (_____________________) {
if (______________________) {
if (_______________________) {
if (________________________) {
if (_________________________) {
if (__________________________) {
if (___________________________) {
if (____________________________) {
if (_____________________________) {
if (______________________________) {
if (_______________________________) {
if (________________________________) {
if (_________________________________) {
if (__________________________________) {
if (___________________________________) {
if (____________________________________) {
if (_____________________________________) {
if (______________________________________) {
if (______________________________________) {
if (_______________________________________) {
} else {
________________________________________ = require('lodash');
}
} else {
_______________________________________ = require('lodash');
}
} else {
______________________________________ = require('lodash');
}
} else {
_____________________________________ = reqeire('lodash');
}
} else {
____________________________________ = require('lodash');
}
} else {
___________________________________ = require('lodash');
}
} else {
__________________________________ = require('lodash');
}
} else {
_________________________________ = require('lodash');
}
} else {
________________________________ = require('lodash');
}
} else {
_______________________________ = require('lodash');
}
} else {
______________________________ = require('lodash');
}
} else {
_____________________________ = require('lodash');
}
} else {
____________________________ = require('lodash');
}
} else {
___________________________ = require('lodash');
}
} else {
__________________________ = require('lodash');
}
} else {
_________________________ = require('lodash');
}
} else {
________________________ = require('lodash');
}
} else {
_______________________ = require('lodash');
}
} else {
______________________ = require('lodash');
}
} else {
_____________________ = require('lodash');
}
} else {
____________________ = require('lodash');
}
} else {
___________________ = require('lodash');
}
} else {
__________________ = require('lodash');
}
} else {
_________________ = require('lodash');
}
} else {
________________ = require('lodash');
}
} else {
_______________ = require('lodash');
}
} else {
______________ = require('lodash');
}
} else {
_____________ = require('lodash');
}
} else {
____________ = require('lodash');
}
} else {
___________ = require('lodash');
}
} else {
__________ = require('lodash');
}
} else {
_________ = require('lodash');
}
} else {
________ = require('lodash');
}
} else {
_______ = require('lodash');
}
} else {
______ = require('lodash');
}
} else {
_____ = require('lodash');
}
} else {
____ = require('lodash');
}
} else {
___ = require('lodash');
}
} else {
__ = require('lodash');
}
} else {
_ = require('lodash');
}
The advantage to this pattern is that it allows the lodash
library to be loaded into 40 different variables. That’s an advantage, right?