-
예제
{ console.log("call start"); (async function (params = "test function1") { console.log(params); })(); (async () => { let rst = new Promise(resolve => { setTimeout(() => { console.log('timeout1 end'); setTimeout(() => { console.log('timeout2 end'); resolve('promise resolved'); }, 1000); }, 1000); }).then((rst:any) => { console.log('promise then rst: ' + rst); }); console.log("before await"); await rst; console.log("after await"); })(); console.log("call end"); }
결과
'Html Css JavaScript' 카테고리의 다른 글
bootstrap Ex navs (0) 2023.01.21 Alert message bar Ex (0) 2023.01.21 Css, Style 적용 방식 (내부, 외부, 직결, external, internal, inline) (0) 2023.01.18 javascript window, document (0) 2023.01.03 Promise 개요 (0) 2022.12.25 async await Ex1 (0) 2022.12.24 Promise Ex1 (0) 2022.12.24 async await 개요 (0) 2022.12.24