Skip to content

Instantly share code, notes, and snippets.

@robinhouston
Created January 7, 2016 14:56
Show Gist options
  • Save robinhouston/b69a434377b5f8acf240 to your computer and use it in GitHub Desktop.
Save robinhouston/b69a434377b5f8acf240 to your computer and use it in GitHub Desktop.
Testing Safari’s strange treatment of declared global variables
<!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