function getACar(param1, param2, param3, callback) {
constructWheels(param1, function (wheels) {
constructBody(param2, function (body) {
constructCar(param3, callback);
});
});
}
function constructWheels(param, callback) {
var wheels = {};
// ...
callback(wheels);
}
function constructBody(param, callback) {
var body = {};
// ...
callback(body);
}
function constructCar(param, callback) {
var car = {};
// ...
callback(car);
}
getACar('a','b','c', function (car) {
console.log('I got a brand new car');
});