hi i have small doubt in understanding the difference of the following.
the following code did not worked:-
window.setTimeout(hello(),3000);
function hello(){
alert("ju");
}
But the following code worked fine:-
window.setTimeout(function(){hello();},3000);
function hello(){
alert("ju");
}
So what is the difference between the two. In the first code snippet i have called a function directly in setTimeout. In the second code snippet i have written an anonymous function and have called my function inside it. The first one did not worked and second one worked fine. So what is the difference and how to understand this?