4 ms·
> Functions that take a callback argument are called asynchronous functions. Just to nit pick... Passing a callback to a function as an argument doesn't magica
by Xophmeister 12y ago
> Functions that take a callback argument are called asynchronous functions.
Just to nit pick... Passing a callback to a function as an argument doesn't magically make that function asynchronous, in JavaScript. For example:
var block = function(callback) {
while(true) {}
callback();
};
Only those functions that are implemented asynchronously (such as Node.js' fs.readdir, from the article's example) will actually be asynchronous.
- echaozh 12y agoAsynchronicity doesn't necessarily mean the function will be call at a later time. Rather it should mean the function will not be called by me at a previously known time without knowing the implementation of the function I am calling. Encapsulation, you know. Using callbacks means giving up control of when things will happen. The fact that it will actually happen very soon is out of the question.