await3 Javascript Async, Await 심화 # Javascript Async, Await 심화 ```javascript // wait ms milliseconds function wait(ms) { return new Promise(r => setTimeout(r, ms)); } async function hello() { await wait(1500); return 'world'; } hello() .then(function(r,j){ console.info(r,j); }) .catch(function(e){ console.info(e); }); // ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== // wait ms milliseconds function wait(ms) { return new.. 2019. 7. 12. Javascript Async return Promise For await # Javascript Async return Promise For await ## # async function #### Reference - [https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Statements/async_function](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Statements/async_function) #### async function - async function 선언은 AsyncFunction객체를 반환하는 하나의 비동기 함수를 정의한다. - 또한 async function expression을 사용해서 async function을 선언.. 2019. 7. 12. Javascript Async, Await 심화 Javascript Async, Await 심화 ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== // wait ms milliseconds function wait(ms) { return new Promise(r => setTimeout(r, ms)); } async function hello() { await wait(1500); return 'world'; } hello() .then(function(r,j){ console.info(r,j); }) .catch(function(e){ console.info(e); }); ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== // wait ms millise.. 2019. 1. 30. 이전 1 다음