I just came across this question in one of my interviews. I did not receive a response, putting it on StackOverflow
One simple question in JS, but I can not understand the reason for this. Below is the code.
var f = function foo(a, b) { console.log(a + "-" + b);
Now, if I do f(1,2) , then it works fine.
But if I do foo(1,2) , then it says an undefined function .
Why is this happening? why can't a function be called with a function name after assigning the function to js?
source share