I have a function that does something like this:
function do_something() {
// some code
return $.when(foo, bar, baz).then(do_something_else);
}
function do_something_else(_foo, _bar, _baz) {
// do something else
return /* the original inputs */;
}
So, when someone uses do_something
, they can also chain more callbacks, like:
do_something().then(function(_foo_2, _bar_2, _baz_2) {
console.log(_foo_2, _bar_2, _baz_2);
});
The problem is that I don't know how to bypass the original return from do_something_else
to the anonymous function described. I don't want to receive a list, but positional arguments instead, so "when foo" inserts some value to do_something_else's _foo and then the same value goes to _foo_2.
How can I do it in JS?