Answers for "static variable in javascript"

12

static variable in javascript

<script>
  class Example {
    static staticVariable = 'code_breaker';
   //static variable defined
   static staticMethod() {
     return 'staticVariable is : '+this.staticVariable;
      }
  }
  // static method called
  console.log(Example.staticMethod());
</script>
Posted by: Guest on August-18-2021
0

javascript function static variable

javascriptCopyfunction getId() {
    if ( typeof getId.counter == 'undefined' ) {
        getId.counter = 0;
    }
    alert(++getId.counter);
}
Posted by: Guest on July-02-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language