Articles → JavaScript → Static And Non-Static Method In Javascript
Static And Non-Static Method In Javascript
Static Methods
class StaticMethodClass {
constructor() {}
static message() {
alert("Static method");
}
}
// Calling static method
StaticMethodClass.message();
Non-Static Methods
class NonStaticMethodClass {
constructor() {}
message() {
alert("Non Static method");
}
}
// Calling non-static method
var obj = new NonStaticMethodClass();
obj.message();