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 283 views
1 answer 297 views
2 answers 389 views
2 answers 421 views
421 views asked Nov 4, 2015 by avibootz
1 answer 284 views
2 answers 303 views
...