View Single Post
  #4 (permalink)  
Old 11-07-09, 01:36 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
interval and killer are variables local to the functions they are declared in.

The var statement, outside the function, establishes the variable so that all functions can get to it. If the var is inside a function, the variable is only available inside that function. To learn more, go to W3Schools and look up 'javascript variable scope'.

Code:
var interval;

function executeExample()
{
interval=setInterval("doSomething()",5000);
}

function clearExample()
[
clearInterval(interval);
}
Reply With Quote