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

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -