I have been recently reading function expression and declaration in javascript and have referred to quite a few online articles about this. I also have seen quite a few discussion about this topic on SO. In the process of learning I tasked myself with a challenge, which I am not able to clearly explain. Can I kindly request SO experts to help me gain some insight here?
Here is the problem scenario -
Scenario 1:
>var multFunc=function(n){var a=2; return n*a;}
>multFunc(6)
12
I understand this scenario and the result is what I was expecting (12).
Scenario 2:
>var multFunc1=function(n){return function(n){n*2}}
>multFunc1(6)
function (n){n*2}
I did not understand the second case. Why would it not return 12? Can someone please help me understand this? I have checked this link - Javascript Function Expressions, this link JavaScript Nested function and I also did ask a similar question yesterday, but I guess I did not fully grasp the concept (as explained graciously by T.J) - Trying a closure the wrong way?