alert(myVar1);
return false;
var myVar1;
Above code throws error in IE, FF and Opera stating that return statement has to come in the function. But
This code makes little sense:
var myVar1
will never be ran. return false;
will not return a thing since you're not in a functionOpera, IE and FF are right to throw an error because this code is really not valid since you're not able to return unless you are in a function.
If it works in Safari and Chrome it must be because the javascript engine they use is ready to handle buggy code. My guess would be that they see the "return
" and drop or replace it with some kind of break
.
More information about functions: http://www.w3schools.com/js/js_functions.asp