Created
January 7, 2016 14:56
-
-
Save robinhouston/b69a434377b5f8acf240 to your computer and use it in GitHub Desktop.
Testing Safari’s strange treatment of declared global variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Test declared variable behaviour</title> | |
</head> | |
<body> | |
<div id="foo"></div> | |
<script> | |
var foo; // Declaring the variable should override the default assignment of the div to it? | |
if (foo) { | |
document.write("Your browser is behaving strangely. Is it perchance Safari?"); | |
} | |
else { | |
document.write("Your browser is behaving as I would expect."); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment