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====
无厘头冲动回帖
------------------------------------------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====
无厘头冲动回帖
====CSDN====
无厘头冲动回帖
<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>