Today there was a question in JavaScript tag, Difference between function f(){} and f = function(){} which is very similar to a canonical question var functionName = function() {} vs function functionName() {}. But the similarity is only in the title text. The actual problem is different in the new question. The canonical question explains the differences between function declaration and function expression. But the new question doesn't use var
keyword so the function actually becomes global.
Actually it was dup-closed earlier by a Gold Hammer and I reopened it with mine. Now I went back to that question and found that it was closed by 5 other people as dup.
As it is closed now, search engines may not list that question at the top if somebody else has a similar problem. Since I exhausted my reopen vote for that question, what is the best possible way to get that opened again?
Edit: As Jereon suggested, I was thinking about editing the title to make it clear, but I couldn't come up with a clear title.
Edit 2: Before posting the question here, I tried to engage one of the Dup close voters in chat
global.f = function(){};
? Put thatglobal.
in the title.global
is actually applicable to Node.js environment :( This question is not specific to any environment.alert
, it looks likewindow.f =
may also be a valid way to write it.this
need not refer to the global object always. So, technically, it doesn't imply what OP meant.Difference between function expression in global scope and function declaration
. Now I am afraid the actual solution is in the title itself :(