node之 promise

来源:互联网 发布:linux ioremap 编辑:程序博客网 时间:2024/06/15 08:48

参考:官方
术语
promise:一个function 或者Object 紧跟then方法的
thenable:用来指定的then方法的function或者Object
value:including undefined, a thenable, or a promise
exception:throw 抛出异常
throw: is a value that indicates why a promise was rejected
声明 promise states
pending:等待
fulfilled:成功
rejected:失败
1.promise.then(onFulfilled, onRejected)
如果onFulfilled或者onRejected不是函数,那就忽略
If onFulfilled is not a function, it must be ignored.
2.如果onFulfilled或者onRejected是函数
promise2 = promise1.then(onFulfilled, onRejected);
以上是个人笔记,参考者需要有自己的理解

原创粉丝点击