Possible Duplicate:
Difference between using var and not using var in JavaScript
There are two ways I've seen people declare functions in javascript. Either:
foo = function()
{
//Do stuff
}
or
var foo = function()
{
//Do stuff
}
I'm new to javascript, and would like to know if there is a real difference between the two. Is one better to use than the other, or does it depend on the situation?