JSFiddle - React, Tailwind, and code Playground

by camnpr

JavaScript

// 可以传递function的时候不要传递string (如:setTimeout时候)

function testFunc(){
     alert("OK");   
}

setTimeout("testFunc()", 1000); // 不建议

setTimeout(testFunc, 2000); // 建议

setTimeout(function testFunc(){alert("OK");}, 3000); // 建议