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.