Click here to Skip to main content
15,896,386 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all, I'll be so grateful If I could figure out to determine the idle time of javascript setTimeout function, that is, I want to use it in an "if statement" as a condition if idle or not evaluating to a boolean true or false, such as:

JavaScript
 if (setTimeout(iGotTheAnswerByMyself(), 7000000000000) { 
// do something if you get an answer before time is out
thankYourForAnsweringBeforeTimeOut();
}



Thanks a lot for your efforts in advance!
Posted
Comments
Dholakiya Ankit 19-Jul-13 23:40pm    
but i think if your settimeout once started it can not be sorted or conditioned you have to find something else

1 solution

Nice humorous formulation of the question, I appreciate it.

This is about 222 years. I don't think I need to rush with the answer. I hope this time would be enough for you to read JavaScript documentation. The function is so simple that it will be too easy to meet this deadline. And hundreds of times more useful. :-)

Good luck,
—SA
 
Share this answer
 
Comments
[no name] 20-Jul-13 0:07am    
Thanks Sergey, don't make me beg! I'm a newbie to javascript. Thanks!!
Sergey Alexandrovich Kryukov 20-Jul-13 0:12am    
No problem, but I'm not just joking. Really, read documentation on this API with attention, it will make it clear. Pay attention: JavaScript is loosely typed, so it will return the result you define in your function, no matter what it is.
—SA
[no name] 20-Jul-13 0:32am    
Thanks a lot Sergey! And I equally thank you Dholakiya for your answer and time. All so helpful.
Sergey Alexandrovich Kryukov 20-Jul-13 0:40am    
You are welcome. If you, except for explaining some confusion, will also explain your goal, chances are, we will give your more useful help.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900