M
Matìj Cepl
Hi, I have many calls of methods inside of lambda functions in a object
method:
obj.prototype.methodA = function() {
var that = this;
... doing something ...
list.forEach(function(x) { // or it might be a callback in XHR
that.methodB(x);
}
.... doing something else ...
}
I am slightly bothered about all those that = this lines. There are too
many of them (basically one in every non-trivial function I have). Do I
something wrong? Is there a better way how to achieve the same result
with some less cludgy means?
In case it is FAQ (as it should be, but I haven't found it anywhere), I
am sorry and please point me to the URL of the FAQ explaining this.
Thanks a lot,
Matìj
--
http://www.ceplovi.cz/matej/, Jabber: mcepl<at>ceplovi.cz
GPG Finger: 89EF 4BC6 288A BF43 1BAB 25C3 E09F EF25 D964 84AC
Besides, the determined Real Programmer can write Fortran
programs in any language.
-- Ed Post, Real Programmers Don't Use Pascal
method:
obj.prototype.methodA = function() {
var that = this;
... doing something ...
list.forEach(function(x) { // or it might be a callback in XHR
that.methodB(x);
}
.... doing something else ...
}
I am slightly bothered about all those that = this lines. There are too
many of them (basically one in every non-trivial function I have). Do I
something wrong? Is there a better way how to achieve the same result
with some less cludgy means?
In case it is FAQ (as it should be, but I haven't found it anywhere), I
am sorry and please point me to the URL of the FAQ explaining this.
Thanks a lot,
Matìj
--
http://www.ceplovi.cz/matej/, Jabber: mcepl<at>ceplovi.cz
GPG Finger: 89EF 4BC6 288A BF43 1BAB 25C3 E09F EF25 D964 84AC
Besides, the determined Real Programmer can write Fortran
programs in any language.
-- Ed Post, Real Programmers Don't Use Pascal