Skip to content

Instantly share code, notes, and snippets.

@biologyscience
Created August 3, 2022 15:58
Show Gist options
  • Save biologyscience/e27a13cc1d528232de39200221a58262 to your computer and use it in GitHub Desktop.
Save biologyscience/e27a13cc1d528232de39200221a58262 to your computer and use it in GitHub Desktop.
take advantage of global scoping
const a = document.getElementById('a');
const aVal = parseInt(a.value);
const b = document.getElementById('b');
b.value = aVal + 5;
<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