The function declaration in JS refers to the following form:
function functionname () {}
Such a way to declare a function, whereas a function expression is like an expression that declares a function, such as:
var functionname = function () {}
Perhaps a lot of friends in the reading of these two kinds of writing will produce doubts, these two are similar, in the application seems to be feasible, then they are what difference?
In fact, the parser of JS does not treat function declaration and function expression equally. For a function declaration, the JS parser will read first, ensuring that the declaration has been parsed before all code executes, and that the function expression, like a variable of other primitive types, will be parsed only when executed to a certain sentence, so in practice, they will be different. When you define a function using the form of a function declaration, you can call the method before the function declaration, and the latter, if you do so, will error.