async

function timeout(ms) {
  return new Promise((resolve) => {
    setTimeout(resolve, ms);
  });
}

async function asyncPrint(value, ms) {
  await timeout(ms);
  console.log(value)
}

asyncPrint('hello world', 50);
 

http://www.ruanyifeng.com/blog/2015/05/async.html

posted @ 2017-06-02 13:35  boyanh  阅读(162)  评论(0编辑  收藏  举报