I
I
Ivan Kuznetsov2014-08-16 00:52:02
JavaScript
Ivan Kuznetsov, 2014-08-16 00:52:02

Why doesn't prototype see the variable from the constructor?

learn.javascript.ru/play/HviXUb Clicking
on the block should display Hello World, but world = undefiend. If you just call this.hello () in the constructor, then everything works
---
while I'm considering such a solution from the options, but maybe it's possible somehow else?

...
var that = this;
...
this.div.on('click', function(){
that.hello()
})
...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2014-08-16
@meam

think in the right direction.
https://developer.mozilla.org/en-US/docs/Web/JavaS...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question