• Is made up of statements contained with <script> </script> tags within an html page
  • The JavaScript statements tell the browser what to do
  • IsĀ case sensitive!
  • Ignores whitespace (spaces, tabs, newlines)
  • Semi-colons are optional, but highly recommended
    • If omitted, new statements should appear on a new line
  • Comments, same as C/C++
    • //text after double forward slash
    • /* text between slash-star, across multiple lines */
    • recognises html comment <!-- as being the same as //
      • html closing comment --> is not recognised and should be written as //-->


This JavaScript uses document.write to output some simple HTML to the page, opens an alert box and display the rest of the HTML. Comments have been included to show various styles:

			//A single line comment
			document.write("<h1>Welcome to your first JavaScript!</h1>");
		<p>A JavaScript popup alert box will now appear!<br>
		followed by more text when you click OK on the popup...</p>
			*  A multiple
			*  line comment
			alert("Hello, World!")
		<p>Here's some more text!</p>

Save & refresh browser:

Welcome to your first JavaScript!

A JavaScript popup alert box will now appear!
followed by more text when you click OK on the popup...

Here's some more text!


*note: running the above will initially display the first three lines of text and a popup alert box, followed by the final line when the OK button is clicked upon

Leave a Reply