编辑代码

// const sleep = (timeountMS) => new Promise((resolve) => {
//     setTimeout(resolve, timeountMS);
// });

// (async () => {  // 声明即执行的 async 函数表达式
//     for (var i = 0; i < 5; i++) {
//         await sleep(1000);
//         console.log(new Date, i);
//     }
//     console.log("run now")
//     await sleep(1000);
//     console.log(new Date, i);
// })();


var a = 2;
(function(def){
  def(window);
})(function def(global){
  var a = 3;
  console.log(a);
  console.log(global.a);
})