0

how to call non static method into static method

i written this class and when run this class

class Test{

    constructor(p){

        this.fname = p;
    }

    change(n){
        this.fname = n + ' test';
    }

    static show(){
        this.change('iman');
        return  this.fname;
    }

    echo(){    
        return this.fname+' ok';
    }
}

console.log(Test.show());

return below error

TypeError: this.change is not a function
A.Azadi
  • 21
  • 3
  • https://stackoverflow.com/questions/2042813/calling-non-static-method-in-static-method-in-java – Vladimir Feb 23 '22 at 16:16
  • Does this answer your question? [ES6: this within static method](https://stackoverflow.com/questions/50285240/es6-this-within-static-method) – PM 77-1 Feb 23 '22 at 16:17

0 Answers0