1

I am a newbie in javascript programing . I want to use one property to other property in exact same functon .But confused how to write. That code:

    function foo(){}
      foo.prototype.bar = "bar";
      foo.prototype.doBar = ()=>{ let d = this.bar; return d; }

      newFoo = new foo();
      newFoo.doBar() // shows undefined 

when I call newFoo.doBar() then it gives an undefined value.plz let me khow why .

And what will be the correct Code inside foo.prototype.doBar() method.

0 Answers0