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
Post a Comment