The JScript Version of Hello World!
The following console program is the JScript version of the traditional "Hello World!" program, which displays the string Hello World!.
// A "Hello World!" program in JScript. print("Hello World!");
The important points of this program are the following:
The first line of the example contains a comment. Since the compiler ignores the comment, you can write any text. This comment describes the purpose of the program.
// A "Hello World!" program in JScript.
The double forward slash (//) means that the rest of the line is a comment. You can make an entire line a comment, or you can append a comment to the end of another statement, as follows:
var area = Math.PI*r*r; // Area of a circle with radius r.
You can also use multiline comments. A multiline JScript comment begins with a forward slash and asterisk (/*), and ends with the reverse (*/).
/* Multiline comments allow you to write long comments. They can also be used to "comment out" blocks of code. */
For more information, see.
This example uses the print statement to display the string Hello World!:
For more information, see print Statement.
There are other ways for a program to communicate with the user. The classexposes methods and properties that facilitate interaction with the person using the console. For more information, see Console. The class exposes methods and properties that facilitate interaction with the user using Windows Forms. For more information, see .
Compilation and Execution
You can compile the "Hello World!" program using the command line compiler.
To compile and run the program from the command line
Create the source file using any text editor and save it using a file name such as Hello.js.
To start the compiler, enter the following at the command prompt:
You should compile the program from the Visual Studio Command Prompt. For more information, see.
If your program does not contain compilation errors, the compiler creates a Hello.exe file.
To run the program, enter the following at the command prompt: