JScript Language Elements

| Tutorial | Reference |

Statements and Comments
A JScript statement consists of one or more items and symbols on a line. A new line begins a new statement, but it is a good idea to terminate your statements explicitly. The semicolon (;) is the termination character.

EXAMPLES:
aBird = "Robin";
var today = new Date();
A single-line JScript comment begins with a pair of slashes (//). (NOTE: these are forward slashes, not backslashes.) A multiline comment begins with "/*", and ends with "*/". (Those who are familiar with the C programming language will recognize these forms.)

EXAMPLE:
aGoodIdea = "Reduce, reuse, recycle.";   //  This one is crucially important.

/*  For the purpose of this example, we are assigning a value to the
aGoodIdea variable. The value, which is contained within the quotemarks, is called a
literal. A literal explicitly and directly contains information, rather than
referring to the information indirectly. (The quotemarks are not, themselves, part
of the literal.)
     After this statement is executed, you can refer to the content of
the variable by using the name of the variable. For an example, see the next
statement.
*/
document.write(aGoodIdea);   //  This writes out the saying (not the name of the variable!)
                             //   in the browser window.
A group of JScript statements, surrounded by angle brackets, is called a block. Blocks of statements are used (for example) in functions and conditionals.

EXAMPLE:
function importune()  
{
        document.write("Please?");
        document.write("<br>");
        document.write("PRETTY please??");
}



© 1996 by Microsoft Corporation.