function _promise(resolver){
this.status='pending';
this.result='';
resolver(this.resolve.bind(this),this.reject.bind(this));
}
function _promise.prototype.resolve(){
if(this._status==='pending'){
this._status='fulfilled';
this.result=result;
}
}
function _promise.prototype.reject(){
if(this._status==='pending'){
this._status='rejected';
this
前端面试之手撕代码实现promise和其then、all、race、filnally方法
最新推荐文章于 2024-05-01 22:08:46 发布
本文深入探讨了JavaScript ES6中的Promise对象,通过手动编写代码来理解其核心方法包括then、all、race和finally的工作原理。详细解释了每个方法的实现逻辑和在异步操作中的作用,帮助前端开发者深化对Promise的理解。
摘要由CSDN通过智能技术生成