Q:

Why doesn't this code result in recursion?

Given this code:
function foo()
{
  if (!foo)
  {
    //blah blah blah some code here
    foo = true;
  }
}

What exactly does this do?  Why is it not creating a recursive call?

A:

This might create a recursion : 
function foo()
{
  if (!foo()) // <=== notice the ()
  {
    //blah blah blah some code here
    foo = true;
  }
}

But there, without the parenthesis, foo isn't executed. The tests only checks the variable foo doesn't evaluate as true, and then replaces it with the boolean true. It's a weird code but not a recursion.
Note that we're not sure, inside the function, that foo is the function, as the code could be like this :
function foo() {
  if (!foo)
  {
    //blah blah blah some code here
    foo = true;
  }
}    
var f = foo;
foo = 0;
f(); // this would result in foo being true

