How to call static method from class constructor in JavaSript

1 Answer

0 votes
class StaticMethodsClass 
{
    constructor()
    {
        document.write(StaticMethodsClass.staticMethod()); 
    }
    static staticMethod() 
    {
        return 'Static method';
    }
}
 
var obj = new StaticMethodsClass(); 

/*
run:

Static method 

*/

 



answered Aug 18, 2016 by avibootz

Related questions

1 answer 245 views
1 answer 284 views
2 answers 346 views
1 answer 267 views
1 answer 240 views
...