12.8. Miscellaneous Statements
For multiline comment blocks, you can begin a block with the /* symbol. Comment blocks may run any number of lines. The block is closed with the */ symbol, after which the interpreter engages subsequent statements. Example// convert temp from C to F /* many lines of comments */
The "conditional" part comes from numerous global properties (all preceded with the @ symbol) that reveal environmental properties, such as script engine version, operating system, and CPU type. All of this information is available from the navigator object's properties on a wide range of browsers, so this is not unique information available only to this conditional environment. To engage conditional compilation, include the following statement in your script: /*@cc_on @*/ This is a one-way toggle: once the mode is turned on, it can't be turned off in the current page. The following fragment shows how the @if and related statements display some environmental information in the window's status bar if the browser is running JScript Version 5.6 or later (IE 6 or later): The @set statement lets you assign a numeric or Boolean value (no strings) to a variable (a variable with an @ prefix) within a conditional compilation section: @set @isOK = @_win32 Once initialized, that variable (including its otherwise unacceptable identifier) can be used in script statements throughout the page. Note that the Visual Basic-inspired syntax of @ statements in conditional compilation statements does not permit semicolons at the end of statements. On the one hand, conditional compilation could be useful for IE-only deployment to screening older IE versions from new language features that would generate compilation errors (such as try-catch constructions) because such statements compile only under very controllable version situations. In a multibrand browser development shop, however, at most you might find application for IE-only debugging purposes, but probably not for actual application deployment. ExampleSee the discussion above.
Example
You may simply declare one or more variable names, in which case their initial values are null. Or you can also initialize a new variable with a value. Examplevar a, b, c; var myName = "Susan";
Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|