标签:
setTimeout函数delay时间之后执行一次func.
setTimeout函数原型:
var timeoutID = window.setTimeout(func, [delay, param1, param2, ...]); var timeoutID = window.setTimeout(code, [delay]);//not recommended for the same reasons as using eval() //param1, param2, and so forth are additional parameters which are passed through to the function specified by func.
区别:
//In Broswer function f(){ alert("H"); } function f2(){ setTimeout("f()", 2000); } window.onload = f2; //In Node.js function f(){ console.log("H"); } function f2(){ setTimeout(f, 2000); } f2();
标签:
原文地址:http://www.cnblogs.com/bukekangli/p/4644303.html