JavaScript Guidelines
Some other important things to know when scripting with JavaScript.
JavaScript Is Case Sensitive
A function named myfunction
is not the same as myFunction
and if
, a command, is not the same as IF
, a variable.
White Space
JavaScript ignores extra spaces.
You can add white space to your script to make it more readable.
For example, the following two lines are equivalent:
var name="Hege";
var name = "Hege";
Comments
You can add comments to your script by using
- two slashes
//
(a one-line comment) or
/*
and */
(a multi-line comment block).
Breaking up a Code Line
You can break up a code line within a text string with a backslash.
The example below will be displayed properly:
document.write( "Hello \
World!" );
However, you cannot break up a code line like this:
document.write \
( "Hello World!" );
but the following code is all right:
document.write
( "Hello World!" );
Demonstration
The following demonstration shows how the script of HTML and JavaScript is displayed on the Web.
How did the gum cross the road?
It was stuck to the chicken’s foot.
— Sam Jay
|