The JScript scripting language, based on a Microsoft implementation of the ECMA 262 language, has been overhauled and improved to support integration with the .NET Framework. The improvements include support for compiled code, type and type less variables, cross-language integration, and access to all of the .NET Framework classes and resources. In addition, there are enhanced performance features supporting faster script execution that can be used in conjunction with ASP.NET. All of these enhancements are geared towards providing a more flexible and robust environment for developing high performance applications with the .NET Framework while leveraging scripting technologies.
Here's how to create and compile a simple class. First define a class in JScript.NET with a simple member function that returns a string, for example:
// Jscript.NET code
function GetString() : string
Next, compile the class into a .NET assembly. You can use JScript compiler jsc.exe to compile the code using the command line. For the example class, you would write:
jsc.exe /target:library MyClass.js
The preceding command creates a file named MyClass.dll
, which you can then reference just like any other .NET assembly. Precompiled script code provides a huge performance advantage over traditional script interpretation, and in addition, you can interoperate with the JScript.NET classes from any other .NET language.