Namespaces


Namespaces are a way of logically grouping related code. This is a logical organization and doesn’t affect the runtime in any way.

namespace MyNamespace {
    export const myValue: number = 10;
}

Exercise

Create a namespace named Geometry. Inside this namespace, define two functions - one to calculate the area of a rectangle, and another for the area of a circle.


Copyright © learn-ts.org. Read our Terms of Use and Privacy Policy