2014-04-22 10:31 GMT+03:00 Glenn Block <[email protected]>: > Douglas Crockford recommends "that" as the alias for this which is an > approach that I prefer over self. Self reminds me of Python :-) > > When I see `that` instead of `self` I think to myself: "oh, that person never reads any code" because if you've been reading `self` in 99% of the code out there you wouldn't be doing something else just because a random person of authority said so.
> > On Mon, Apr 21, 2014 at 9:44 PM, Andrey <[email protected]> wrote: > >> In addition all previous comments: >> I don't like name 'self' as alias to 'this' ( I tend to interpret same >> way as 'this', e.i context of current function). Instead, use same name you >> would use for your object instance. Example: >> >> Client.prototype.doStuff = function() { >> var client = this; >> // ... some async code here >> setTimeout(function() { >> client.doneTimeout(); // I think it's more explicit than >> self.doneTimeout() >> }, 100); >> }; >> >> >> >> On Tuesday, 22 April 2014 06:11:14 UTC+10, Reza Razavipour wrote: >>> >>> I see a lot of code that does >>> var self = this >>> >>> and then they use self instead of this for the duration of the function? >>> >>> Why and when would you use the above pattern? >>> >>> >>> -- >> -- >> Job Board: http://jobs.nodejs.org/ >> Posting guidelines: >> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines >> You received this message because you are subscribed to the Google >> Groups "nodejs" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/nodejs?hl=en?hl=en >> >> --- >> You received this message because you are subscribed to the Google Groups >> "nodejs" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > > --- > You received this message because you are subscribed to the Google Groups > "nodejs" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
