4 ms·
That way is longer without reason, you must first define in the function scope both variables error and result; the latter only receives assignation when no err
by jQueryIsAwesome 14y ago
That way is longer without reason, you must first define in the function scope both variables error and result; the latter only receives assignation when no error has been generated.
function doAsyncCall(callback){
var error, result;
// .. do some async stuff
// assign error if there was one or result when everything went fine
if( !error ){ result = data; }
callback(error, result);
}