How to use static methods in classes with JavaScript

1 Answer

0 votes
class Worker {
    constructor(id, name) {
        this.id = id;
        this.name = name;
    }
    static show() {
        console.log("show()");
    }
}
 
const w = new Worker(2345, 'Tom');
 
Worker.show();



     
/*
run:
   
show()
 
*/

 



answered Mar 6, 2020 by avibootz

Related questions

1 answer 196 views
1 answer 188 views
2 answers 266 views
2 answers 310 views
310 views asked Nov 4, 2015 by avibootz
2 answers 191 views
1 answer 196 views
...