javascript - Why doesn't this code result in recursion? -


given code:

function foo() {   if (!foo)   {     //blah blah blah code here     foo = true;   } } 

what do? why not creating recursive call?

this might create recursion :

function foo() {   if (!foo()) // <=== notice ()   {     //blah blah blah code here     foo = true;   } } 

but there, without parenthesis, foo isn't executed. tests checks variable foo doesn't evaluate true, , replaces boolean true. it's weird code not recursion.

note we're not sure, inside function, foo function, code :

function foo() {   if (!foo)   {     //blah blah blah code here     foo = true;   } }     var f = foo; foo = 0; f(); // result in foo being true 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -