JScript

JScript 8.0 is a modern scripting language with a wide variety of applications. It is a true object-oriented language, and yet it still keeps its "scripting" feel. JScript 8.0 maintains full backwards compatibility with previous versions of JScript, while incorporating great new features and providing access to the common language runtime and .NET Framework.

JScript 8.0 is used for applications that run on a server by using the .NET Framework. For information about writing scripts that run on a client computer in a Web browser, The following topics introduce the essential components of JScript 8.0 and provide information about how to use the language. As with any modern programming language, JScript supports a number of common programming constructs and language elements.

If you have programmed in other languages, much of the material covered in this section may seem familiar. While most of the constructs are the same as in previous versions of JScript, JScript 8.0 introduces powerful new constructs similar to those in other class-based, object-oriented languages.

If you are new to programming, the material in this section will serve as an introduction to the basic building blocks for writing code. Once you understand the basics, you will be able to create powerful scripts and applications using JScript.

JScript 8.0 represents a major advance of the JScript language in several ways. With tighter integration into the Visual Studio development environment, multiple new features, and access to the .NET Framework classes, moving from JScript to JScript 8.0 may appear at first to be a daunting task.

In reality, almost all of the changes represent additional functionality, while the core JScript functionality is the same as in previous versions. Practically all JScript scripts will run without modification under JScript 8.0 (with the fast mode turned off). To run in fast mode (the mode supported by ASP.NET), some scripts will need minor modifications.

It is easy to make the transition from JScript to JScript 8.0 since you can include the new features into your code gradually.

JScript 8.0 is a true object-oriented scripting language. Although JScript 8.0 can now use classes, types, and other advanced language features for writing robust applications, it retains its "scripting" feel, with support for typeless programming, expando functions and classes, dynamic code execution (using eval), and more.

In addition to being a typeless language, JScript 8.0 can now be a strongly typed language. In previous versions, the loosely typed structure of JScript meant that variables assumed the type of the value assigned to them. In fact, you could not declare the data types of variables in previous versions. JScript 8.0 provides more flexibility than previous versions of JScript by allowing variables to be type annotated. This binds a variable to a particular data type, and the variable can store only data of that type.

There are many advantages of strong typing in a programming language. In addition to the benefit that occurs when you use a data type that properly fits the data you are using, you get several other benefits:

Improved execution speed

Run-time/compile-time type-checking

Self-documenting code

Finally, it is important to remember that JScript 8.0 is not a condensed version of another programming language, nor is it a simplification of anything. It is a modern scripting language with a wide variety of applications.

The Visual Studio Integrated Development Environment (IDE), which is the common development environment for all languages, provides tools and validation schemes that help you write reliable code. The IDE also provides debugging features that help you reconcile inconsistencies and resolve coding mistakes.

A JScript program may display information through different procedures depending on the use of the program. There are three common ways to use JScript: in an ASP.NET page, in a client-side Web page, and from the command line.

There are three ways that JScript displays data from a command-line program. The Microsoft JScript command-line compiler provides the print statement. The class Console provides additional methods that facilitate interaction with the user using the console.

The Show method displays information and receives input from pop-up boxes.

The JScript programming language includes an assortment of properties, methods, objects, functions, and so on. In addition, JScript can use many corresponding features from the .NET Framework class library.