JavaScript Comments:
·
Comments will
not be executed by JavaScript.
·
Comments can be
added to explain the JavaScript, or to make the code more readable.
·
Single line
comments start with //.
- Multi line comments start with /* and end with */.
JavaScript Variables:
·
JavaScript
variables can be used to hold values (x=5) or expressions (z=x+y).
·
Variable can
have short names (like x and y) or more descriptive names (age, sum, total_volume).
- Variable names are case sensitive (y and Y are different variables)
Declaring JavaScript Variables
·
You declare
JavaScript variables with the var keyword:
·
In Javascript, when you're setting up a variable you start
with the letters var (short for variable, of course). After a space, you
then need to come up with a name for your variable (like a). You can't have
spaces in your variable
The name can be almost anything you want. But there are some important considerations. These are:
·
You can't start
your variable name with a number
·
The variable
should contain only letters, numbers ( but not the first
character of the variable), a dollar sign ($) and an underscore ( _ )
·
Variable names
must begin with a letter
Here are some valid variable names:
number1
number_1
$firstName
And here are some invalid variables names:number_1
$firstName
1number
mob number
"firstName"
Literal:
- Literal is variable value,
constant value or expression, which represents a value.mob number
"firstName"
No comments:
Post a Comment