I am trying to understand how js parser works and wonder why there is no error in a declaration of var a below:
> var a = function b() {return 1;}
undefined
> typeof a
'function'
> typeof b
'undefined'
> function c() {return 1;}
undefined
> typeof c
'function'
> var d = function () {return 1;}
undefined
> typeof d
'function'
I think that:
- named function MUST be declared as c(),
- if you want to use function as var, you MUST declare it like d(use anonymous function)
I do not understand what is the difference between var a and var d declaration.
Can somebody tell me why function identifier is allowed in var declaration and what is the meaning of b in this case?