1
I was taking a look at some posts here on the site and I came across this question here. Well, the accepted answer explained the statement of expression of functions, anonymous, named and self-appointed. Causing my doubt on the named function. What is the function name for if the value of the return
is in the variable name and not in the function name. What is the purpose of naming a function that is inside a variable?
//expressão anônima de função
var a = function() {
return 3;
}
//expressão nominada de função
var a = function bar() { // dúvida para que serve bar
return 3;
}
//expressão "autoinvocada" de função
(function digaOi() {
alert("Oi!");
})();
In my view it is a duplicate "Possible" because I believe the linked answer already explains the difference in the part Example of scope visibility and in my understanding instead of opening a question you could comment on in the answer, but it is only my opinion, for it to be considered accurate duplicate of the vote of other users.
– Caique Romero
Yes I saw Example of scope visibility, I still don’t understand it. There it is in the example ** var functionDois = Function banana() { banana() }** right? Just called banana, how do I work with the function banana. I can do it like this: var funcaoDois = Function banana() { banana() { console.log("Something")}. }. That’s what made me doubt.
– LeAndrade
Give a read on the other answers of the same link they complement each other.
– Caique Romero
Interestingly, the same question was asked yesterday by another user. I marked as duplicate of the same question I pointed out in the case of yesterday, let us know if the content there (+ the answers here) do not solve your question.
– bfavaretto