Difference between function declaration and function expression?

Difference between function declaration and function expression?

Function declaration

The first difference is name, when you create a function with a name, that is a function declaration( not an anonymous function).

code.png

Function expression

A function expression work just like a function declaration or a function statement, the only difference is that a function name is not started in a function expression, it is assigned in a variable, that is an anonymous function is created.

code.png

Thank you.

© 2022 开源博客 京ICP备20030565号-2 Powered by Quick API team