I am trying to figure out how I can execute my JavaScript callbacks in a different style.
My current callback style passes the callback to the function and the function calls the callback. For instance:
Function call
doSomething(function(data){ console.log(data); });
Function
function doSomething(callback) {
This is the current callback style I'm using. But I saw libraries that execute their callbacks in a different style. For instance:
Function call
doSomething().success(function(data){ console.log(data); });
How does it work, and can someone provide a simple example for me? Thank you for your time.
source share