Since the comparison happens before var is declared, it will always evaluate to 'true'. I believe the author was thinking about something like so:
(function(name) { var cmp = function() { return name=="tim"; }; var name; return cmp();})("tim");
This still evaluates to true, but I believe it has to do with the rules of shadowing. If you change the declaration to 'var name="bob";' it will return false.
Comments
Since the comparison happens before var is declared, it will always evaluate to 'true'. I believe the author was thinking about something like so:
This still evaluates to true, but I believe it has to do with the rules of shadowing. If you change the declaration to 'var name="bob";' it will return false.