In function foo, a is just being used as an identifier or a call back if you will.
In function bar, you are stating that var a has the value of 1 from inside the scope of the function which wouldn't be called until you return b() that has a as an expression. For bar(a) "the first parameter" a is being used when you call bar(2) is where the a is being used as identifier/callback. I'm bad at explaining things lol. I don't know if this will help you or hurt you lol.