当我们想要按顺序依次执行多个then函数时,以下两种方式有何不同:
1- 使用嵌套的thens
很明显第二个更易读,但它的性能是否有差异呢?
1- 使用嵌套的thens
$http.get('api').then(function(){
processBlocks(obj.data).then(function(){
alert('it is done')
});
});
2- 将嵌套的then语句展开
$http.get('api').then(function(){
return processBlocks(obj.data);
}).then(function(){
alert('it is done')
});
很明显第二个更易读,但它的性能是否有差异呢?