I am making a game and I wanted to know how to use a variable from a different file. Ex:
var js = "js";
Yes, it can... As long as it's a global variable.
In your HTML, you will need to include the script that declares this variable first. Otherwise it will complain that the variable is undefined.
var globalNumber = 10;
alert(globalNumber); // Will alert "10"
<script src="script1.js"></script> <script src="script2.js"></script>