How to define and use static method in class with JavaScript

1 Answer

0 votes
<script type="text/JavaScript">   

class Worker {
  
  static staticMethod() {
    return 'I am static method'
  }
}

document.write(Worker.staticMethod());

/*
run:

I am static method 

*/

</script>

 



answered May 29, 2016 by avibootz

Related questions

1 answer 284 views
1 answer 280 views
1 answer 279 views
1 answer 320 views
1 answer 296 views
1 answer 286 views
...