Objects can group related helper functions when a small program does not need separate files.

Module-Like Objects

module.ts
type FormatMode = "short" | "long";

const LessonTools = {
    title(name: string): string {
        return name.trim().toUpperCase();
    },
    format(name: string, mode: FormatMode): string {
        const title: string = this.title(name);
        return mode === "long" ? `Lesson: ${title}` : title;
    },
};

const mode: FormatMode = ;
const label: string = LessonTools.format(" typescript ", mode);

console.log(label);
type FormatMode = "short" | "long";

const LessonTools = {
    title(name: string): string {
        return name.trim().toUpperCase();
    },
    format(name: string, mode: FormatMode): string {
        const title: string = this.title(name);
        return mode === "long" ? `Lesson: ${title}` : title;
    },
};

const mode: FormatMode = ;
const label: string = LessonTools.format(" typescript ", mode);

console.log(label);
module object A module-like object keeps related values and functions under one clear name.