I'm going crazy - can js redirect a link within scope?
If I am right, is this a serious bug in Firefox 22.0?
if (true) { test(); function test() { alert("success"); } }
The above code does not work with test () undefined. If the code is executed outside the if statement (or if only the function definition has been moved outside the if ??? statement), then everything will be fine. The same error occurs (not defined) inside other areas, for example, do .. while, etc.
The code above works fine in both IE and Chrome, etc.
* update *
I'm not sure if it is stupid or unreasonable to expect it to be able to do this (of course, it makes sense semantically in the sudo code), but the gods js decided that only statements can appear in such blocks (as mentioned in the link that refers to spidermonkey / ECMA stuff from basilikum) - so no - especially with inconsistent browser processing (if not in strict mode). Thanks to everyone.
source share