Named function expression: Difference between var bar = function () {} & var bar = function foo () {}

Can anyone help in understanding the difference between the following two function expressions:

a) var bar = function() {};
b) var bar = function foo() {};

I wrote how it was written in a). What is the importance of naming the function "foo" in b)?

How is a) different from b)?

+4
source share
2 answers

Method a: a variable with a name barthat refers to an anonymous function. a function can only be used using a variable bar, wherever it is in scope.

b: bar, foo. foo - , bar.

Paulpro - foo , .

+6

, , .

0

Source: https://habr.com/ru/post/1695958/


All Articles