jjzjj

functionReference

全部标签

javascript - .then(functionReference) 和 .then(function(value){return functionReference(value)}) 之间有区别吗?

给定一个用于处理Promise值的命名函数functionhandlePromise(data){//dostuffwith`data`returndata}a)将命名函数handlePromise作为对.then()的引用传递promise.then(handlePromise)b)使用匿名函数或命名函数作为.then()的参数,并以Promise值作为参数返回命名函数handlePromise在传递给.then()的匿名或命名函数的主体内promise.then(function/*[functionName]*/(data){returnhandlePromise(data)})