@@ -836,7 +836,7 @@ Promise.resolve('foo')
836836new  Promise (resolve  =>  resolve (' foo'  ))
837837``` 
838838
839- ` Promise.resolve ` 方法的参数分成四种情况。
839+ ` Promise.resolve()  ` 方法的参数分成四种情况。
840840
841841** (1)参数是一个 Promise 实例** 
842842
@@ -854,7 +854,7 @@ let thenable = {
854854};
855855``` 
856856
857- ` Promise.resolve ` 方法会将这个对象转为 Promise 对象,然后就立即执行` thenable ` 对象的` then ` 方法。
857+ ` Promise.resolve()  ` 方法会将这个对象转为 Promise 对象,然后就立即执行` thenable ` 对象的` then()  ` 方法。
858858
859859``` javascript 
860860let  thenable =  {
@@ -864,27 +864,27 @@ let thenable = {
864864};
865865
866866let  p1 =  Promise .resolve (thenable);
867- p1 .then (function (value ) {
867+ p1 .then (function   (value ) {
868868  console .log (value);  //  42
869869});
870870``` 
871871
872- 上面代码中,` thenable ` 对象的` then ` 方法执行后,对象` p1 ` 的状态就变为` resolved ` ,从而立即执行最后那个` then ` 方法指定的回调函数,输出 42 。
872+ 上面代码中,` thenable ` 对象的` then()  ` 方法执行后,对象` p1 ` 的状态就变为` resolved ` ,从而立即执行最后那个` then()  ` 方法指定的回调函数,输出42 。
873873
874- ** (3)参数不是具有` then ` 方法的对象,或根本就不是对象** 
874+ ** (3)参数不是具有` then()  ` 方法的对象,或根本就不是对象** 
875875
876- 如果参数是一个原始值,或者是一个不具有` then ` 方法的对象,则` Promise.resolve ` 方法返回一个新的 Promise 对象,状态为` resolved ` 。
876+ 如果参数是一个原始值,或者是一个不具有` then()  ` 方法的对象,则` Promise.resolve()  ` 方法返回一个新的 Promise 对象,状态为` resolved ` 。
877877
878878``` javascript 
879879const  p  =  Promise .resolve (' Hello'  );
880880
881- p .then (function  (s ){
881+ p .then (function  (s )  {
882882  console .log (s)
883883});
884884//  Hello
885885``` 
886886
887- 上面代码生成一个新的 Promise 对象的实例` p ` 。由于字符串` Hello ` 不属于异步操作(判断方法是字符串对象不具有 then 方法),返回 Promise 实例的状态从一生成就是` resolved ` ,所以回调函数会立即执行。` Promise.resolve ` 方法的参数,会同时传给回调函数。
887+ 上面代码生成一个新的 Promise 对象的实例` p ` 。由于字符串` Hello ` 不属于异步操作(判断方法是字符串对象不具有 then 方法),返回 Promise 实例的状态从一生成就是` resolved ` ,所以回调函数会立即执行。` Promise.resolve()  ` 方法的参数,会同时传给回调函数。
888888
889889** (4)不带有任何参数** 
890890
@@ -939,23 +939,17 @@ p.then(null, function (s) {
939939
940940上面代码生成一个 Promise 对象的实例` p ` ,状态为` rejected ` ,回调函数会立即执行。
941941
942- 注意, ` Promise.reject() ` 方法的参数,会原封不动地作为` reject ` 的理由,变成后续方法的参数。这一点与 ` Promise.resolve ` 方法不一致 。
942+ ` Promise.reject() ` 方法的参数,会原封不动地作为` reject ` 的理由,变成后续方法的参数。
943943
944944``` javascript 
945- const  thenable  =  {
946-   then (resolve , reject ) {
947-     reject (' 出错了'  );
948-   }
949- };
950- 
951- Promise .reject (thenable)
945+ Promise .reject (' 出错了'  )
952946.catch (e  =>  {
953-   console .log (e ===  thenable )
947+   console .log (e ===  ' 出错了 '  )
954948})
955949//  true
956950``` 
957951
958- 上面代码中,` Promise.reject ` 方法的参数是一个 ` thenable ` 对象,执行以后, 后面` catch ` 方法的参数不是 ` reject ` 抛出的“出错了”这个字符串,而是 ` thenable ` 对象 。
952+ 上面代码中,` Promise.reject()  ` 方法的参数是一个字符串, 后面` catch()  ` 方法的参数 ` e ` 就是这个字符串 。
959953
960954## 应用  
961955
0 commit comments