I did a series of experiments in nodejs console:
> function a(){}
undefined
> a
[Function: a]
> a.name
'a'
> b = function(){}
[Function] // see, the name is empty
> b.name
'' // further proof
> b = function b(){}
[Function: b]
> b.name
'b' // now b behaves just like it's defined
// by "function b(){}"
Judging from what I can test, function a() {}
serves as a shorthand of a = function a() {}
. Is this how engines like V8 internally do? Is there a difference between a
and b
in the above experiment?