well, the two options have pros and cons as told in the duplicate post. If you use:
var functionOne = function () { … }
function functionTwo () { … }
then functionOne
won't exist in the block prior to its definition, and is being defined at runtime. Whereas the other option, functionTwo
is defined at parse time and can be called anywhere in the program. Another thing that changes is the behavior of this
inside the function.
So basically, your question is:
- how do I want to scope my function?
- if scope does not matter, do I prefer run time or parse time?
To get the full answers to those questions, I really advice you to read and reread the short book from Crockford "Javascript the good parts", and it looks like @wumm's suggested article is pretty relevant as well.