If I call an if statement as such:
if(someRandomFunction()){
//do stuff
}
If the called function returns true but after various invoked delays and timed animations, does this cause the if statement to fail?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you say “various invoked delays and timed animations”, I presume you are talking about calls to
window.setTimeout()and such.When a function registers a delayed event like this, the function continues executing after registering the event, and the event fires later, usually after the registering function has finished executing.
The things that get executed later are also functions. They can return values, but since those functions are actually called by the browser (when it knows it is time for them to be called), the values get returned to the browser. In the case of
setTimeout()andsetInterval()at least, the return value is ignored.When you call a function, you can (in javascript at least) count on that function to be the one that returns the value to you.