I have a function with this form:
function main () {
if(!false){
if(document.addEventListener){
document.addEventListener("touchstart", do_something);
document.addEventListener("click", do_something);
}
function do_something(){
//doing something here
}
}
}
My problem is that in firefox (but not in chrome or safari), the listener throws an error: ReferenceError: do_something is not defined
I thought that functions defined in that form were always read before execution, and functions defined as var do_something(){}
are read at execution time.
Is this correct? Why is this happening only on Firefox?
EDIT: More info: if I mote it before the if, the function works and no error shown