📜  settimeout 函数 javascript for 循环 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:16.904000             🧑  作者: Mango

代码示例5
// make sure to use "let" and not "var" if you want to capture
// the value of the external variable in a closure

  for (let i = 0; i < 5; i++) {
    setTimeout(() => console.log(i), 0);
  }