Last active
July 22, 2018 08:54
-
-
Save kejiweixun/44e26ac939c99c69801c4a7726227698 to your computer and use it in GitHub Desktop.
Revisions
-
kejiweixun revised this gist
Jul 22, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -45,3 +45,4 @@ console.log(result); //5 //3 //6 //[ 'c', 'b', 'a' ] -
kejiweixun revised this gist
Jul 22, 2018 . 1 changed file with 11 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,4 +34,14 @@ a().then(function(result){ console.log(result); }); console.log(result); // -1 //0 //1 //9 //4 //2 //5 //3 //6 -
kejiweixun created this gist
Jul 22, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ let result = 9; function a(){ console.log(-1) return new Promise(function(resolve, reject){ console.log(0) resolve('a'); console.log(1) }); }; function b(message){ return new Promise(function(resolve, reject){ console.log(2) resolve('b' + message); }); }; function c(message){ return new Promise(function(resolve, reject){ console.log(3) resolve('c' + message); }); }; a().then(function(result){ console.log(4) return b(result); }).then(function(resultFromB){ console.log(5) return c(resultFromB); }).then(function(resultFromC){ console.log(6); [...result] = resultFromC; console.log(result); }); console.log(result);