My guess: it's part of the inner guts of Node.js I have a tentative breadcrumb
See https://github.com/joyent/node/blob/master/lib/fs.js#L31 that binding.stat is internally mapped to this Stat function: https://github.com/joyent/node/blob/master/src/node_file.cc#L353 notice ASYNC_CALL(stat, args[1], *path) That ASYNC_CALL is https://github.com/joyent/node/blob/master/src/node_file.cc#L225 #define ASYNC_CALL(func, callback, ...) \ FSReqWrap* req_wrap = new FSReqWrap(#func); \ int r = uv_fs_##func(uv_default_loop(), &req_wrap->req_, \ __VA_ARGS__, After); \ req_wrap->object_->Set(oncomplete_sym, callback); \ req_wrap->Dispatched(); \ if (r < 0) { \ uv_fs_t* req = &req_wrap->req_; \ req->result = r; \ req->path = NULL; \ req->errorno = uv_last_error(uv_default_loop()).code; \ After(req); \ } \ return scope.Close(req_wrap->object_); There is a NEW object, req_wrap, enriched with the callback in its property oncomplete_sym My guess: when the callback is finally called, that req_wrap object is used as its "this". But it's only guess All this, apparently, is relative to fs module. On Wed, Jun 6, 2012 at 9:23 AM, Jérémy Lal <holi...@gmail.com> wrote: > I don't think it tells why the result of the snippet is : > > { oncomplete: [Function] } > > I still can't tell what is this object... does node.js follow > some convention about the context in which a function is called back > from a library call ? > > Jérémy. > > > On 06/06/2012 14:06, Anand George wrote: > > This should help... http://howtonode.org/what-is-this > > > > On Wed, Jun 6, 2012 at 5:23 PM, Jérémy Lal <holi...@gmail.com <mailto: > holi...@gmail.com>> wrote: > > > > Hi, > > > > require('fs').stat('file.txt', function(err, result) { > > console.log(this); // what is this ? > > }); > > > > Jérémy. > > > > -- > > 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 nodejs@googlegroups.com<mailto: > nodejs@googlegroups.com> > > To unsubscribe from this group, send email to > > nodejs+unsubscr...@googlegroups.com <mailto: > nodejs%2bunsubscr...@googlegroups.com> > > 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 nodejs@googlegroups.com > > To unsubscribe from this group, send email to > > nodejs+unsubscr...@googlegroups.com > > 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 nodejs@googlegroups.com > To unsubscribe from this group, send email to > nodejs+unsubscr...@googlegroups.com > 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 nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en