Why do the following codes give different results between Chrome and Firefox?
f = function() {return true;}; g = function() {return false;}; (function() { if (g() && [] == ![]) { f = function f() {return false;}; function g() {return true;} } })(); console.log(f());
In Chrome: the result is false . However, in Firefox, this is true .
The key line of the above codes is line 4, and based on my knowledge of raising the function name, the function g should be on line 6, namely line 2 is redefined by line 6. IMO, the behavior of Chrome is correct.
I'm right? if so, why is Firefox displaying different results?
javascript firefox google-chrome
zangw Aug 04 '14 at 2:37 a.m. 2014-08-04 02:37
source share