Namespace Declaration in TypeScript
📖 Scenario: Imagine you are organizing a small library of books. You want to group related functions and variables under a common name to keep things tidy and avoid name clashes.
🎯 Goal: You will create a Library namespace that contains a list of books and a function to display the books.
📋 What You'll Learn
Create a namespace called
LibraryInside
Library, create a variable books which is an array of stringsInside
Library, create a function showBooks that prints each book nameCall the
showBooks function outside the namespace to display the books💡 Why This Matters
🌍 Real World
Namespaces help organize code in large projects by grouping related code together and avoiding name conflicts.
💼 Career
Understanding namespaces is important for working on TypeScript projects, especially when collaborating with others or managing big codebases.
Progress0 / 4 steps