0
    class Demo{
       varA;
       method=function(){
            alert(this.varA)
             }
    }

this.varA not working above, varA is not accessible.

class Demo{
           varA;
           method= ()=>{
                    alert(this.varA)
                  }
        }

But, this worked. I wonder why?what's the difference between function(){} and ()=>{} in typescript.

Suraj Rao
  • 28,186
  • 10
  • 88
  • 94
H.BCN
  • 35
  • 8

0 Answers0