When implementing a method used only within a specific component class, it can be declared as a static method and an instance method, and I wonder the difference between the two.
Declaring methods of classes used across applications, such as the Util class, static is common, but I wonder if it is the right way to declare static just because it does not refer to this within a particular component class.
According to my research, the static method of class is disadvantageous in terms of memory because the memory remains intact even if the component's life cycle ends. If so, isn't it more advantageous to use it as an instance method even if it's only used within a specific class and not referenced to this?
class MyComponent {
// ex1) instance method
private isValidInput(text) {
return !!text.trim()
}
// ex1) static method
private static isValidInput(text) {
return !!text.trim()
}
}
When implementing component classes using Angular, I wondered if I would implement util functions that are only used in specific component classes as static or instance methods.