Last active
March 16, 2017 02:38
-
-
Save sk8terboi87/2eff633a3037d79952f9fb5947b6bee6 to your computer and use it in GitHub Desktop.
JavaScript Scoping Issues - Example http://codelikeapoem.com/2017/03/javascript-scoping-issues.html
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> | |
<title>Bad Parts</title> | |
<script src="shakespeare.js"></script> | |
<script src="wordsworth.js"></script> | |
<script type="text/javascript"> | |
console.log(getPoem()); | |
</script> | |
</head> | |
<body> | |
The Bad Way - Global | |
</body> | |
</html> |
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
<script type="text/javascript"> | |
var poem = 'The west yet glimmers with some streaks of day.'; | |
function getPoem() { | |
return poem; | |
} | |
</script> |
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
<script type="text/javascript"> | |
var poem = 'Instruct them how the mind of Man become'; | |
function getPoem() { | |
return poem; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment