bonchef bonchef - 9 months ago 109
Javascript Question

Is Node.js asynchronous?

Can I count on nodeIDs mapping is completed every time doSomething() is called?

nodeIDs = $.map(nodeIDs, function(n){
return n.match(/\d+$/);

I thought all callbacks in node.js are asynchronous? I did read an article on general programming that callback could be synchronous but I am not sure about node.js?


JavaScript is also a functional programming language. What you have here is a «higher order function», a function which takes a function as a parameter. Higher order functions are synchronous.


map() is a typical example of a higher order function. It takes a function and applies it to all elements of an array. The definition sounds very «functional». This function is also not provided by Node. It is documented by MDN and specified by ECMAScript 5.1.

To answer your question: Yes, doSomething(nodeIDs) is called after all elements have been applied.