看啥推荐读物
专栏名称: 前端大全
分享 Web 前端相关的技术文章、工具资源、精选课程、热点资讯
今天看啥  ›  专栏  ›  前端大全

那些你熟悉而又陌生的函数

前端大全  · 公众号  · 前端  · 2021-12-25 11:50
一起探索那些你熟悉和又陌生的函数。setTimeout[1] && setInterval[2]语法var timeoutID = scope.setTimeout(function[, delay, arg1, arg2, ...]);var timeoutID = scope.setTimeout(function[, delay]);var timeoutID = scope.setTimeout(code[, delay]);我们最常用的是语法中的第二种var timeoutID = scope.setTimeout(function[, delay]);举个例子setTimeout(()=>{    console.log(`当前时间:${Date.now()}`);}, 1000)接着我们看再看第三种 setTimeout(code[, delay]), code就是代码字符串,其底层实现就是调用eval,你可能问题怎么知道的,因为MDN对这个code参数有解释。code An alternative syntax that allows you to include a string instead of a function, which is compiled and executed when the timer expires. This syntax is not recommended for the same  reasons that make using eval() a security risk.刚才的代 ………………………………

原文地址:访问原文地址
快照地址: 访问文章快照