JScript .NET, 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 .NET is construction of Web sites with ASP.NET and customization of applications with Script for the .NET Framework.Many of the new features in JScript .NET are being developed in conjunction with ECMAScript Edition 4. These include typed and typeless variables, full support of class-based objects (with inheritance, function overloading, property accessors, and more), and packages. JScript .NET also 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.Several new features in JScript .NET were added to 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 .NET. 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 .NET programs use are namespaces, attributes, by-reference parameters, and native arraysFollowing are some of the new features in JScript .NET: 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. Enumerations 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.
javascript真的是神奇,方法似乎也是一种属性,不同的是这种属性的值是一个function而已。// Define the constructor and add instance specific information. function Circle (radius) { this.r = radius; // The radius of the circle. } // Add a property the Circle prototype. Circle.prototype.pi = Math.PI; function ACirclesArea () { // The formula for the area of a circle is pi*r^2. return this.pi * this.r * this.r; } // Add a method the Circle prototype. Circle.prototype.area = ACirclesArea; // This is how you would invoke the area function on a Circle object. var ACircle = new Circle(2); var a = ACircle.area();
把JScript的变量空间用好了。 那么变化就已经够多了。 简单例子 function aa() { var v=Math.random(); function bb() { return v; } return bb; } var b1=aa(); var b2=aa(); alert(b1==b2); alert(b1()+":"+b2()+":"+b1()); 更复杂的例子?http://lostinet.d2g.com/Lostinet-Publish/JScriptSoapClient
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.
Enumerations
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.
不过JScript.net基于.net平台,而不像javascript那样只要有个引擎即可。欢迎大虾们继续参与。
能不用别扭的方法直接实现实现static,extends,abstract....吗?
有点新鲜,楼上的,详细讲来,洗耳恭听....
function Circle (radius) {
this.r = radius; // The radius of the circle.
}
// Add a property the Circle prototype.
Circle.prototype.pi = Math.PI;
function ACirclesArea () {
// The formula for the area of a circle is pi*r^2.
return this.pi * this.r * this.r;
}
// Add a method the Circle prototype.
Circle.prototype.area = ACirclesArea;
// This is how you would invoke the area function on a Circle object.
var ACircle = new Circle(2);
var a = ACircle.area();
有利于共享和代码升级
runmin(悠悠 稻草人)说的“真的是神奇”,不知道是不是为了弥补js的非OO而引入的,用惯了真正的OO语言倒觉得有一点别扭。欢迎大家继续。尤其是以下问题:
如果要设计这样一种OO脚本语言,它应该具有什么样的功能(至少JS所能做到的它也应该做到吧)?应该弥补JS的哪些不足(包括功能、使用等方面)?应该在哪些方面与新技术相结合?:)
那么变化就已经够多了。
简单例子
function aa()
{
var v=Math.random();
function bb()
{
return v;
}
return bb;
}
var b1=aa();
var b2=aa();
alert(b1==b2);
alert(b1()+":"+b2()+":"+b1());
更复杂的例子?http://lostinet.d2g.com/Lostinet-Publish/JScriptSoapClient
不过代码还在写中。。
MS也不多推广一下