1function a() {
2 return new Promise(function(resolve) {
3 setTimeout(function() {
4 console.log('a');
5 resolve();
6 }, 500)
7 });
8}
9
10function b() {
11 return new Promise(function(resolve) {
12 setTimeout(function() {
13 console.log('b');
14 resolve();
15 }, 250);
16 });
17}
18
19a().then(b).then(function() {/* do something else */})