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
.
Created
December 20, 2012 04:04
-
-
Save reggi/4342900 to your computer and use it in GitHub Desktop.
Callback and error handeling examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
something_async({ | |
success:function(data){ | |
console.log(data); | |
}, | |
error:function(error){ | |
console.log(error); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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