What Is JScript .NET?
JScript .NET is the next generation of an implementation by Microsoft of the ECMA 262 language. Combining the feature set of previous versions of JScript with the best features of class-based languages, JScript .NET includes the best of both worlds. Improvements in JScript .NET — which is being developed in conjunction with ECMAScript Edition 4 — include true compiled code, typed and typeless variables, late- and early-binding, classes (with inheritance, function overloading, property accessors, and more), packages, cross-language support, and full access to the .NET Framework.
Programs written in JScript .NET can be used in many contexts. The script engine in a Web browser runs a script that is embedded in a Web page. Windows Script Host runs a script that is embedded in an ASP or ASP.NET page. JScript .NET programs can also be compiled (using jsc.exe, the new JScript command-line compiler) to create executable programs.
JScript .NET is a true object-oriented scripting language. Although JScript .NET 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 .NET 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 .NET 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 .NET 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.
Note The code in many of the included JScript .NET examples is somewhat more explicit and less dense than in actual scripts. The intent is to clarify the concepts rather than to express optimal coding conciseness and style. In any case, there is no shame in writing code that you can read and easily understand six months after you write it.