Statements run in the DOM sequentially, one after the other.
Every browser has something called a JavaScript interpreter built into it.
[scripts.js]
alert("Hello, world!");
<script src="scripts.js"></script>
What is one benefit of putting your JavaScript code just before the closing </body> tag on a web page?
Browsers run JavaScript code as soon as they encounter it. Putting the code after the page content assures that visitors will be able to see the contents of the web page BEFORE the JavaScript program runs.
Input/Output
alert("Hello, world!");
document.write("Hello, world!"); // writes output at the end of the doc
console.log("Program complete");
console.log( program, ': ', "Program complete" );
prompt("What is your name?"); // returns a string, or null on cancel
Variables
Variable names are case-sensitive.
Variable names can only contain letters, numbers, underscores, or dollar signs.
$perPound Yes you can begin a variable name with $ or _.
var num1;
num1 = 10;
var num1= 10;
var message = 'She\'s a great person!';