Sample code:
<span style="font-size:18px;">function hi(){ var a = 1; return function(){ console.log(a++); }; }; var aaa = hi();var bbb = hi;</span>As above code:
aaa is to assign the run result of hi() to it, that is, the anonymous function returned by return. At this time, there is a closure, and the same a is accessed every time aaa is called. The first run result of aaa() is 1 and the second time is 2
And bbb will assign the function name hi to it, and then call bbb() and return a function expression, that is, function(){console.log(a++)};
The above article briefly talks about the difference between the name of the function with brackets and without brackets when calling functions in JS. This is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.