This document discusses working with JavaScript and variables. It provides:
1) An overview of how JavaScript code is placed in HTML and how comments are written.
2) An analogy that variables are like boxes that store content, with the variable name on the box and the stored data as the content.
3) Rules for naming variables in JavaScript, including that names are case sensitive, must begin with a letter or underscore, and keywords cannot be used. Meaningful names are recommended.
1 of 4
More Related Content
Lesson 4 maya 3
1. Working with JavaScript
The Javascript code is placed between <body> and
</body> tags in HTML.
The start of javascript code begins as <script
type=text/javascript> and </script> tags.
You would find a semicolon at the end of a
javascript statement. (;)
A comment phrase begins with a //. Phrases can
be introduced to make the program more readable.
This would not be executed by computer
2. Variables
Variables can be compared to small boxes with names.
If you were to store 5 pair of shoes, you might have a box
for each pair. On each box you would write what is in it.
The boxes would be your variables.
(Places to store things.)
The name on the boxes would be the variable names.
( The ones you'd use when referring to each of the boxes.)
And finally the shoes, would be the content of the
variables.
(What is stored in the boxes.)
3. Rules of Variables
We must follow a set of rules for creating a
variable in JavaScript such as-
Names are case sensitive. For example
LENGTH is not the same as length.
Variable name should begin with a letter or
underscore (_). For example 3number is a
wrong variable name.
4. Rules of Variables
Keywords (special words that are used for
specific purposes by javascript, should not
be used as variable names.
It is recommended to use meaningful
variable names. For example first name is
Firstname.