Modules & Namespaces - Concepts
Explore the key concepts of modules & namespaces with practical examples and exercises.
45 min•By Priygop Team•Last updated: Feb 2026
Introduction to Modules & Namespaces
In this section, we cover the fundamental aspects of modules & namespaces. You'll learn core concepts, see real-world examples, and understand how to apply them in your projects.
Key Concepts
- Understanding the core principles of modules & namespaces
- Practical applications and real-world use cases
- Step-by-step implementation guides
- Common patterns and best practices
- Tips for debugging and troubleshooting
- Performance optimization techniques
Modules & Namespaces - Code Example
Example
// ES Modules in TypeScript
// math.ts
export const PI = 3.14159;
export function add(a: number, b: number): number { return a + b; }
export default class Calculator {
multiply(a: number, b: number): number { return a * b; }
}
// main.ts
import Calculator, { PI, add } from "./math";
import type { User } from "./types"; // Type-only import
console.log(add(2, 3));
const calc = new Calculator();
console.log(calc.multiply(4, 5));Try It Yourself: Modules & Namespaces
Try It Yourself: Modules & NamespacesJavaScript⚠ 1 error
⚠ Syntax Issues (1)
✕
Line 1: JS Error: Unexpected identifier 'Logger'
💡 Check syntax near the highlighted line.
JavaScript Editor
✕ 1 errorTab = 2 spaces
JavaScript|14 lines|396 chars|1 error, 0 warnings
UTF-8