The variable is initialized in the previous <script type= "Text/javascript" ></script> (or the referenced JS file) and can be accessed normally.
Run the program: Eject 123.
<script type= "Text/javascript" > var a = 123; </script><script type= "Text/javascript" > alert (a); </script>
Variables are initialized in the <script type= "Text/javascript" ></script>, the variables are initialized in the code after they are accessed, and the variables are not accessed (defined but not valued).
Run the program: Eject undefined.
<script type= "Text/javascript" > alert (a);
var a = 123;
</script>
The variable is initialized in subsequent <script type= "Text/javascript" ></script>> (or the referenced JS file) and is not accessible (equivalent to undefined).
Run Program: Error, hint A is undefined.
<script type= "Text/javascript" > alert (a); </script><script type= "Text/javascript" > var a = 123;
</script>
JavaScript Variable initialization location