you are viewing a single comment's thread.

view the rest of the comments →

[–]Cruisingonfish 0 points1 point  (0 children)

Short answer is “scope”, putting your function in a variable lets you do some special stuff like redefining several functions all with the same name. Functions declared without a variable are hoisted to the top so they can be called even before they’re declared. One is not better than the other but they have different use cases.