DEV Community

Discussion on: Why Do JS Devs Hate Namespaces?

Collapse
 
bytebodger profile image
Adam Nathaniel Davis

yet in javascript nobody does this, despite it being possible in just the same way (except for the syntax, of course).

I appreciate that confirmation! As I was writing the article, I couldn't help but wonder whether this lack of namespacing was just in my head. But yeah - I don't understand why the approach you've shown above is almost never taken in JS.

In fact, as I outlined in the section about destructuring, it honestly feels to me like JS devs are ruthlessly going in the other direction - purposely stripping variables of all context. I'm not exaggerating when I say that I've read JS code where I had to repeatedly refer back to the top of the function to understand the values that particular variables were supposed to hold - because all of those variables had been destructured out of their original object.