Why you might want to create static class members?
Why you might want to create static class members?
Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Aviance School is one of the largest web solutions platform in India for developers to learn and share their programming knowledge and build their careers.
Because Static method calls are made directly on the class and are not callable on instances of the class. Static methods are often used to create utility functions.
Classes Static:
class StaticMethodCall {
constructor() {
console.log(StaticMethodCall.staticMethod());
// expected output: “static method has been called.”
}
static staticMethod() {
return ‘static method has been called.’;
}
}
new StaticMethodCall();