We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class Promises { // 三种状态 pending(进行中)、fulfilled(已成功)和rejected(已失败) /** * 常用方式Promise.resolve(something).then(...) * 可见Promise.resolve返回一个新的Promise实例 **/ static resolve() { } static reject() { } status = 'pending' callback = () => { } constructor(fn) { fn(this._resolve.bind(this), this._reject) } _resolve(value) { this.callback(value) } _reject() { } then(fn) { this.callback = fn } } var aa = new Promises((resolve, reject) => { setTimeout(() => { resolve(1) }, 2000) }) aa.then((value) => { console.log('value', value, this) })
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: