1console.log("Start");
2console.time("Promise");
3await new Promise(done => setTimeout(() => done(), 5000));
4console.log("End");
5console.timeEnd("Promise");
6
1function delay(n) {
2 n = n || 2000;
3 return new Promise(done => {
4 setTimeout(() => {
5 done();
6 }, n);
7 });
8}
9