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 174 views
1 answer 206 views
2 answers 261 views
1 answer 170 views
1 answer 158 views
...