class staticClass{
static myMethod(){
return 'My Method';
}
method2(){return 'Method 2';}
}
var s = new staticClass();
console.log(s.method2()); // 'Method 2'
console.log(staticClass.myMethod()); // 'My Method'
console.log(s.myMethod()); // 's.myMethod is not a function'
Why are we not able to access static methods via an object in Javascript
In Java we can access static methods via objects. They are different languages yes, but is there any reason behind this design
s.myMethod()instead ofstaticClass.myMethod()?