How can I use one prototype property to other prototype property in same function?

时间:2017-08-05 10:56:17

标签: javascript function prototype

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 个答案:

没有答案