What's the difference between chained .then
and next function call, for example:
funcThatReturnsPromise().then((a) => {
}).then(doSomething)
With
var b;
funcThatReturnsPromise().then((a) => {
b = a;
});
doSomething(b);
EDIT I've tried it, it does the same:
var p2; var p1 = new Promise(function(resolve, reject) {
resolve(p2 = 'test1');
});
p1.catch(function(e){console.log('b',e)});
console.log('c',p2);
// result: c test1
vs
var p1 = new Promise(function(resolve, reject) {
resolve('test2');
});
p1.then(console.log).catch(function(e){console.log('b',e)});
// result: test2