Take this for example.
if (b) b = 1;
Reference Error. b is not defined. Makes sense but if I do this...
if (b) var b = 1;
I get undefined in console. and now when I look up what b is it shows as undefined.
If I try to do the same if statement again, it doesn't pass because b is neither true or false, it is undefined, but I guess my question is why does it show up as undefined? Does Javascript go through the if statement regardless if the if statement passes or fails? Thanks.