Microsoft® JScript Writing JScript Code |
| Tutorial |
|
A Microsoft JScript code 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.
aBird = "Robin"; var today = new Date();A group of JScript statements that is surrounded by braces is called a block. Blocks of statements are used, for example, in functions and conditionals. In the following example, the first statement begins the definition of a function, which consists of the block of five statements that follows. The last three statements, which are not surrounded by braces, do not constitute a block and are not part of the function definition.
function convert(inches) { feet = inches / 12; // These five statements are in a block. miles = feet / 5280; nauticalMiles = feet / 6080; cm = inches * 2.54; meters = inches / 39.37; } km = meters / 1000; // These three statements are not in a block. kradius = km; mradius = miles;
A single-line JScript comment begins with a pair of forward slashes (//). A multiline comment begins with a forward slash and asterisk in combination (/*), and ends with the reverse (*/).
aGoodIdea = "Comment your code thoroughly."; // This is a single-line comment. /* This is a multiline comment that explains the preceding code statement. The statement assigns a value to the aGoodIdea variable. The value, which is contained between the quote marks, is called a literal. A literal explicitly and directly contains information, rather than referring to the information indirectly. (The quote marks are not part of the literal.) */ // This is another multiline comment, written as a series of single-line comments. // After the statement is executed, you can refer to the content of the aGoodIdea // variable by using its name, as in the next statement, in which a string literal is // appended to the aGoodIdea variable by concatenation to create a new variable. var extendedIdea = aGoodIdea + " You never know when you'll have to figure out what it does.";
If you are just beginning to become familiar with programming, please be aware that the equal sign (=) is used in JScript to indicate the action of assigning a value. That is, if a JScript code statement says
anInteger = 3;it means "Assign the value 3 to the variable anInteger," or "anInteger gets 3." When you need to compare two values to find out whether they are equal, use a pair of equal signs (==). This issue is discussed in detail in conditionals.
The term expression, in JScript, is something that a human being can read as a Boolean or numeric expression. Expressions contain symbol characters like "+" rather than words like "added to". Any legal combination of values, variables, operators, and expressions constitutes an expression.
var anExpression = "3 * (4 / 5)"; var aSecondExpression = "Math.PI * radius * 2"; var aThirdExpression = aSecondExpression + "%" + anExpression; var aFourthExpression = "(" + aSecondExpression + ") % (" + anExpression + ")";
© 1996 by Microsoft Corporation.
file: /Techref/language/asp/js/313.htm, 4KB, , updated: 1996/11/22 10:12, local time: 2024/11/29 23:17,
3.144.93.34:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.ecomorder.com/techref/language/asp/js/313.htm"> Microsoft® JScript Language Tutorial </A> |
Did you find what you needed? |
Welcome to ecomorder.com! |
Welcome to massmind.ecomorder.com! |
.