看到一个js中sleep的例子,挺好玩的

4. 0 & undefined = 0

3.留个坑,react后端渲染

2. js中的...扩展运算符可以遍历所有实现Iterable的对象

  const arr = ['c','d'];

  const arr2=['a', ...arr, 'f']

1. promise 实现sleep

async function test() {
  console.log('Hello')
  await sleep(1000)
  console.log('world!')
}

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

test();

原文地址:https://www.cnblogs.com/gugege/p/7444505.html