Please consider this code :
function A() {
console.log("first");
}
var f = A;
function A() {
console.log("second");
}
var g = A;
f();
g();
It outputs "first", "second" in firebug, which is what I thought it should do.
But it outputs "second", "second", in Chrome's console, or in firefox (when executing from a file, not in firebug).
Why should the reference kept in 'f' be changed I do the second "function A() {" ??
It seems like hoisting is the problem (see apsillers' answer bellow). But then, why does this example work correctly (I mean output first-second) :
var A = function A() {
console.log("first");
}
var f = A;
A = function A() {
console.log("second");
}
var g = A;
f();
g();
The fact that I used "A = ..." in the second function declaration blocks the hoisting of this function ?