Even without the 'this' inside process.nextTick it returns the same result.

On Wed, Jun 6, 2012 at 7:05 PM, Diogo Resende <[email protected]>wrote:

> The _this_ inside process.nextTick seems quite odd to me..
>
> --
> Diogo Resende
>
> On Wednesday, June 6, 2012 at 14:31 , Anand George wrote:
>
> Hi!
>
> Have been reading up on process.nextTick and found this one rather odd.
> It's forcing the calling function to run again.
>
> function addasync(no1, no2, result)
> {
>  res = no1 + no2;
> this.result = result(false, res);
> process.nextTick(function() {
>  this.result = result(true, res);
> });
> };
>
> addasync(1, 2, function(err, res) {
> console.log(res);
> });
>
> function addsync(no1, no2) {
> return (no1 + no2);
> }
>
> console.log(addsync(4, 2));
>
> When I run this code I get the following output.
>
> 3
> 6
> 3.
>
> Any ideas why this could be happening.
>
> --
> 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
>
>
>  --
> 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
>

-- 
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

Reply via email to