What distinguishes a static class method from a function defined outside a class in TypeScript, especially when visibility is not a concern?
While there are differences in visibility from other classes and files, what factors should be considered when deciding between using static methods or functions defined outside any classes for a specific use case within a single class?
For 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());
}