![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Javascript
Esaka_Forever
这个作者很懒,什么都没留下…
展开
-
用setTimeout实现一个sleep函数
function sleep (time) { return new Promise((resolve) => setTimeout(resolve, time));}async function main(){ await sleep(1000); console.log(1) await sleep(1000); console.log(2) await sleep(1000); console.log(3).原创 2021-06-20 12:32:06 · 472 阅读 · 0 评论 -
如何让setTimeout方法间隔时间更为精确
functiontimer(){varspeed=500,counter=1,start=newDate().getTime();functioninstance(){varideal=(counter*speed),real=(newDate().getTime()-start);counter++;vardiff=(real-ideal);fo...原创 2021-06-20 12:23:09 · 395 阅读 · 0 评论 -
Async-Await异常处理
1.对于每个await写try catchasync function towerOfTerror(){}原创 2021-06-20 12:05:15 · 110 阅读 · 0 评论 -
JS元编程meta programming
元编程定义:The ablity to treat program as data.The ablity to to read, generate, analyze or transform other programs, and even modify itself while running.1.Macro(sweet.js)可以用宏扩展JS语言2.Reflectionhappens during runtimeReflection有三种1.Introspection原创 2021-05-19 05:48:25 · 100 阅读 · 0 评论