Skip to content

Instantly share code, notes, and snippets.

@reggi
Created December 20, 2012 04:04
Show Gist options
  • Save reggi/4342900 to your computer and use it in GitHub Desktop.
Save reggi/4342900 to your computer and use it in GitHub Desktop.
Callback and error handeling examples

Callback and error handeling examples. I guess the question is: which is a better way to write callbacks? Just by seeing what I've wrote now, I can see that one is much smaller, so in terms of code golf option2.js is the better bet, but as far as which is cleaner, I prefer option1.js.

something_async({
success:function(data){
console.log(data);
},
error:function(error){
console.log(error);
}
});
something_async(function(error,data){
if(error) console.log(error);
console.log(data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment