0% found this document useful (0 votes)
22 views

Getting To Know JavaScript

To use JavaScript, you need a basic understanding of HTML and CSS. JavaScript code can be written directly in an HTML document or stored externally in a .js file. This document includes an HTML page with inline JavaScript that uses document.write() statements to output messages to the browser, demonstrating a basic use of JavaScript. It also introduces JavaScript comments, which start with // for single-line comments and /* */ for multi-line comments.

Uploaded by

Daniel Wood
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Getting To Know JavaScript

To use JavaScript, you need a basic understanding of HTML and CSS. JavaScript code can be written directly in an HTML document or stored externally in a .js file. This document includes an HTML page with inline JavaScript that uses document.write() statements to output messages to the browser, demonstrating a basic use of JavaScript. It also introduces JavaScript comments, which start with // for single-line comments and /* */ for multi-line comments.

Uploaded by

Daniel Wood
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Getting to know JavaScript.

To use JavaScript for web development you need to have a basic understanding
of HTML and preferably some understanding of CSS too to get started. JavaScript
can be written inside an HTML document or it can be stored in a separate .js file
and referred to from an HTML document. Below is an HTML document which
includes a basic JavaScript statement that prints a message to the users
browser. document.write(Your message here); will print a short message. The
semi-colon (;) is used at the end of each JavaScript line it is kind of like using a
period at the end of a sentence.
Comments are used to leave notes about your code and what it does. It is good
practice to use comments in your code. They dont show up in the browser but
they show up in the source code. One-line comments start with // while multi-line
comments start with /* and end with */
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>JavaScript Introduction</title>
<script type="text/javascript">
// prints out message to user
document.write("Hello world</br>");
document.write("Good bye world");
/* remember to use ; at end of each JS statement
This is a multi-line comment
*/
</script>
</head>
<body>
</body>
</html>

Activity 1

1. Copy this code into your own HTML document then save it and run it using
Firefox or Chrome. Remove the </br> tag and see what happens. What
difference does it make when you save the HTML file and refresh the page
in your browser? What is the </br> tag used for?
2. What is the document.write() JavaScript statement used for?
3. What happens when you change document.write to Document.write (with
capital D) and why do you think this happens?
4. What is the meaning of syntax in programming? Why is it important to
follow correct syntax?
5. Using the Internet, research what utf-8 charset is and explain what it
means.

You might also like