What are the practical differences between a static class method, and a function defined outside a class (at the top of the file) in TypeScript?
I know that there are differences regarding visibilty from other classes and files. When visibility is not a concern though (the function/method is only used in one class), when should we use static methods rather than functions defined outside any classes.
Example:
export class Foo {
constructor(bar: string) {
Foo.shout(bar);
}
private static shout(content: string) {
console.log(string.toUpperCase());
}
}
VS
export class Foo {
constructor(bar: string) {
shout(bar);
}
}
function shout(content: string) {
console.log(string.toUpperCase());
}