一起探索那些你熟悉和又陌生的函数。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.刚才的代
………………………………