and it printed "after" before the callback but it could have printed in the correct order, that's the nature of async. You can't expect the callback to finish before the code after it.
I'm not surprised as most things are async in Node.
Also, is https.get technically a function, or method? I wasn't sure when writing the title.
Hi Russell, I did a quick test taking the example in nodejs.org/api/https.html#https_ht... and adding something like:
and it printed "after" before the callback but it could have printed in the correct order, that's the nature of async. You can't expect the callback to finish before the code after it.
I'm not surprised as most things are async in Node.
It's both:
but also
get
is a function operating on (better said "scoped to") the https object, therefore it's a method of the object, but it's also a function.In this case
get
is a method of the objecthttps
which accepts a URL and a function as arguments.Hope this helps!