O'Reilly logo

Designing Active Server Pages by Scott Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating ASP Pages with JScript

Web developers who are familiar with writing client-side JavaScript code already have a good understanding of JScript’s syntax and structure. JScript’s syntax and control structures are also very similar to C’s. For example, JScript’s control structures — if ... else, switch, while, do ... while, and for statements — are syntactically identical to C’s.

Statement Termination

JScript handles its statement termination a bit differently than C. In C, a semicolon is needed to end a statement; in JScript, either a semicolon or a newline character will suffice. Therefore, you can have a JScript statement end without a semicolon as long as the next statement begins on a new line. You can have multiple statements on one line, but then a semicolon must delimit each of these statements. For example, the following code fragment illustrates the legal and illegal use of semicolons and newline characters:

<% @LANGUAGE = "JScript" %>
<% 
   Response.Write("Each new-line character represents")
   Response.Write("a new statement in JScript.  So does a semicolon.<P>")

   // This is legal code:
   Response.Write("Hello, "); Response.Write("World!");

   // This is not:
   Response.Write("Hello, ")  Response.Write("World!");
%>

I highly recommend always ending each statement with a semicolon, regardless of whether the next statement starts on a new line. JScript code examples in this book will adhere to this strict use of semicolons.

JScript’s Variables and Datatypes

JScript does not require ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required