JSFiddle - React, Tailwind, and code Playground
by 533135
HTML
<p id = para>
passing a string to setTimeout (or setInterval) is evil, because it is run in the global scope, has performance issues, is potentially insecure if you're injecting any parameters, etc
</p>
<input id = prop value= 'color'>
every time that piece of code runs JavaScript will have to kick back in to interpreter mode,
JavaScript
var id = document.getElementById("para");
setTimeout('doSomething(someVar)', 5000);
$(function(){
var prop = $("input").val();
// id.style[prop] = "red" bestway
// eval("id.style."+prop+" = 'red'") bad way
});
setTimeout(doSomething('ad'), 2000);
function doSomething(x){
}