Namespaces
Namespaces organize code in the global scope, useful for legacy code or when modules aren't available.
Namespaces
Output
Click Run to execute your code
Note: Prefer ES modules over namespaces for
new projects.
Best Practice: Use ES modules for modern
projects. Namespaces are mainly for legacy code.
Summary
- Namespaces organize global code
- Use
namespacekeyword - Can be nested
- Prefer ES modules for new code
Enjoying these tutorials?