Getting started with JavaScript

This is the first video from a beginners tutorial series on JavaScript. In this video, you will learn how to set up an HTML document to use JavaScript code and how to display a message in the web browser using JavaScript. You will also learn how to write the code in a suitable text editor program and how to test your code using the JavaScript console in Google Chrome.

It will be assumed that you already know basic HTML and CSS so if you don’t then please watch the tutorials on HTML5 and CSS3 here first and then come back to the JavaScript videos.

Watch the video below or click here to watch it on YouTube.

The code below can be copied to a HTML file. The HTML code contains JavaScript code which will basically display a “Hello world” message in the browser window. The code also shows examples of using single-line and multi-line comments. Simply copy and paste the code snippet into a text editor and save the file as yourfilename.html

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="utf-8"/>
 <title>JavaScript intro</title>
 
 <script type="text/javascript">
 
 document.write("Hello world");
 
 // This is a single-line comment
 
 /*
 This is a multi-line comment.
 Line 9 prints a simple message using a write statement.
 The semi-colon means that is the end of the statement. It is placed at the end of the line.
 */
 
 // To check errors you can use Browser Console (Firefox) or Console (Chrome and IE).
 
 </script>
 
</head>
<body>
 
 
</body>
 
</html>

Next tutorial: Variables and data types

Leave a Reply