How to develop node.js run-time strategy?You are correct callback(data) would get called on the spot, it was a bad example from me I am afraid. If you are performing lengthy I/O operations you would be better off using an event emitter. Once the I/O or data generation operation was complete it would then emit a complete event which could contain the callback with the filled out data.
For more information on event emitters see link