JavaScript setTimeout () will not wait for execution?
Consider the following example:
<script type="text/javascript">
function alertBox(){
alert('Hello World!');
}
function doSomething(){
setInterval(alertBox(), 5000); //This is for generic purposes only
};
function myFunction(){
setTimeout(doSomething(),3000);
};
myFunction();
</script>
What does it cause it to execute IMMEDIATELY , and not wait for a 3-second dialing, and also execute only an ONCE warning , and not at the planned 5 second intervals?
Thanks for any help you can provide!
Mason
+5
2 answers