|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
What's New in JScript 8.0?
JScript 8.0, the next generation of the Microsoft JScript language, is designed to be a fast and easy way to access the Microsoft .NET platform using the language of the Web. The primary role of JScript 8.0 is construction of Web sites with ASP.NET and customization of applications with Script for the .NET Framework.
JScript 8.0, which is compatible with the ECMAScript standard, has additional features not specified by ECMAScript, such as true compiled code, cross-language support through Common Language Specification (CLS) compliance, and access to the .NET Framework. While the version of JScript .NET included in Visual Studio .NET 2002 leveraged the inherent security of the .NET Framework, JScript .NET 2003 further helps to maintain security by adding a restricted security context for the eval method.
Several new features in JScript 8.0 take advantage of the CLS — a set of rules that standardizes such things as data types, how objects are exposed, and how objects interoperate. Any CLS-compliant language can use the classes, objects, and components that you create in JScript 8.0. And you, as a JScript developer, can access classes, components, and objects from other CLS-compliant programming languages without considering language-specific differences such as data types. Some of the CLS features that JScript 7.0 programs use are namespaces, attributes, by-reference parameters, and native arrays.
Following are some of the new features in JScript .NET and JScript 8.0:
What's New in JScript 8.0
- /platform compiler option
The /platform option is used to specify the type of processor targeted by the output file: x86 for 32-bit Intel-compatible processors, Itanium for the Intel 64-bit processors, and x64 for AMD 64-bit processors. The default (anycpu) allows the output file to run on any platform.
What's New in JScript .NET 2003
- Restricted Security Context for eval Method
To help maintain security, the built-in eval method now by default runs scripts in a restricted security context, regardless of the caller's permissions. Calling eval with "unsafe" as the optional second parameter causes the script to run with the permissions of the caller, which may allow access to the file system, the network, or the user interface. For more information, see eval Method.
What's New in JScript .NET 2002
- Class-based Objects
JScript .NET (like JScript) supports inheritance through prototype-based objects. JScript .NET also supports class-based objects by allowing you to declare classes that define data and behavior for objects. Classes created in JScript .NET can be used and extended by any .NET language. Classes can inherit the properties and methods of a base class. There are several attributes you can apply to classes and class members that modify their behavior and visibility. For more information, see Class-based Objects.
- JScript Data Types
In JScript .NET (like JScript), you can write programs without specifying data types for your variables. JScript .NET can also be used as a strongly typed language, in which all variables are bound to a specific data type, or you can use a mix of typed and untyped variables. JScript .NET provides many new data types. You can also use classes and .NET types as data types. For more information, see JScript Data Types.
- Conditional Compilation
Directives control compilation of your JScript .NET program. The @debug directive, for instance, turns the emission of debugging information on or off for a particular part of your script. For more information, see @debug Directive. The @position directive sets the line number for the debugger for the current line. For more information, see @position Directive. Both of these directives are useful if you are writing code that will be incorporated in other scripts. For more information, see Conditional Compilation.
- JScript Namespaces
Namespaces prevent naming conflicts by organizing classes, interfaces, and methods into hierarchies. In JScript .NET, you can define your own namespaces. You can also access any .NET Framework namespace with JScript .NET, including ones you define. The package statement enables packaging of related classes for easy deployment and to avoid naming collisions. For more information, see package Statement. The import statement makes a .NET Framework namespace available to a script so that the script can access the classes and interfaces in the namespace. For more information, see import Statement.
- JScript Variables and Constants
JScript .NET introduces a const statement that defines an identifier that represents a constant value. For more information, see JScript Variables and Constants.
JScript .NET introduces the enum statement that allows you to construct enumerated data types. With an enumeration, you can specify helpful names for your data type values. For more information, see enum Statement.