+ 3
Why without () this theres a delay,but with () function is called instantly without delaying for 3secnds..
function onTimeout() { alert("hey maaa"); } var timer=setTimeout(onTimeout(),3000);
1 Antwort
+ 7
because with () you call the function instantly instead of setting a timeout for it
without () you are passing the function to the setTimeout function which creates a timer for a given function
that where the difference lies:
passing a function is done without ()
calling a function is done with ()