Edit: Looks like I was confusing asynchronous I/O with asynchronous function. This answer on another question also helped me in learning. https://stackoverflow.com/a/6738602/1184321
I'm a bit confused on what makes callbacks not synchronous. So I was looking for some clarification on whether or not I need to explicitly denote callbacks in Node.js in order for them to be run asynchronously?
Take the example code:
start(function (err, resp) {
console.log(resp);
});
function start(callback) {
return isTrue(callback);
}
function isTrue(callback) {
return callback(null, true)
}
Is the above example code functionally equivalent to:
start(function (err, resp) {
console.log(resp);
});
function start(callback) {
isTrue(function(err, resp){
return callback(err, resp);
});
}
function isTrue(callback) {
return callback(null, true)
}
Can someone tell if all of these functions would be run asynchronously and if not could some point me in the direction where I can learn more about asynchronous callbacks? The difference between synchronous / asynchronous function calls seems sort of magical to me at this point.
EDIT: