4 ms·
var MyApp = MyApp || {}; This is an anti-pattern, only use it for polyfilling. Use local variable scope!
by z3t4 9y ago
var MyApp = MyApp || {};
This is an anti-pattern, only use it for polyfilling. Use local variable scope!
- mileycyrusXOXO 9y agoI agree this is an anti-pattern; you get better namespace encapsulation by wrapping your code in an immediately invoked function.
- vilmosi 9y agoI used this pattern when you had multiple files extending the same global state. For example when lazy loading based on the page you're on. It can definitely be overused, which is probably why it's an anti pattern, but it had it's uses before webpack.