-
-
Save biologyscience/e27a13cc1d528232de39200221a58262 to your computer and use it in GitHub Desktop.
take advantage of global scoping
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
const a = document.getElementById('a'); | |
const aVal = parseInt(a.value); |
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
const b = document.getElementById('b'); | |
b.value = aVal + 5; |
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
<html> | |
<head> | |
<script src="a.js" defer></script> | |
<script src="b.js" defer></script> | |
</head> | |
<body> | |
<input id="a" type="text" value="10"> | |
<input id="b" type="text"> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment