http://msdn.microsoft.com/library/en-us/dnclinic/html/scripting07142000.asp?frame=true
------------------------------------------JScript .NET Code
// Wrap the function inside a class statement.
class Car
{
   // Declare the class members. I've used types in this example,
   // but they are not required. I could have also ed the class
   // as being 'expando' and not had to declare these members.
   var make : String;
   var color : String;
   var year : int;   // Old constructor function, unchanged.
   function Car(make, color, year)
   {
      this.make = make;
      this.color = color;
      this.year = year;
   }   // Move the function inside the class
   function GetDescription()
   {
      return this.year + " " + this.color + " " + this.make;
   }
}// Create and use a new Car object
var myCar = new Car("Accord", "Maroon", 1984);
print(myCar.GetDescription());
====CSDN====
无厘头冲动回帖

解决方案 »

  1.   

    JScript.net:  server-side JScript,不知道怎么在客户端使用
    ====CSDN====
    无厘头冲动回帖
      

  2.   

    IE似乎目前不支持这么写。不过自定义类还是可以使用的,换种方式罢了。
    <script language="jscript">
    function Car(make, color, year) {
       this.make = make;
       this.color = color;
       this.year = year;
       
       this.GetDescription=GetDescription;   function GetDescription() {
         return this.year + " " + this.color + " " + this.make;
       }
    }
    var car=new Car("Accord", "Maroon", 1984);
    alert(myCar.GetDescription());
    </script>