3 ms·
I thought 'with' was generally frowned upon? Is it guaranteed to work correctly in all situations? And why is this a better namespacing method?
by apu 17y ago
I thought 'with' was generally frowned upon? Is it guaranteed to work correctly in all situations?
And why is this a better namespacing method?
- ed 17y agoYes, "with": - adds an extra look-up when resolving scope - creates code that sometimes isn't immediately obvious But with this technique you basically get to forget you're writing code in a namespace. You can var myFunc; all you want without polluting the global. And you can put the library in a separate file and reference its exposed methods as if they were written in the body of your application.