With thanks to Kurt Cagle of XML Fund. Kurt used to be the DHTML Pro for Dev X, so he got to know Java Script pretty well.
You use the function() keyword:
You can then create a new instance of this, using the name of the class as the constructor:
var car=new Car("Saturn","XJ4i","Silver");
You would then call the properties or methods just as you would for an intrinsic class:
alert(car.transmission + " " + car.make + " " + car.model);
will launch an alert box with the word "Manual Saturn" in it, while
will launch a dialog box with "Putt-putt-putt" in it.
var cr=new Car(make,model,color,numDoors,transmission);
var myNewCar=new CaliforniaCar();
alert("NewCar:In Washington, it leaks!");
alert("NewCar:Not having a sunroof in Washington is a good idea.");
var myOldCar=new Car();
alert("OldCar:In Washington, it leaks!");
alert("OldCar:Not having a sunroof in Washington is a good idea.");
Here is a Java Script Sandbox that uses the eval() function and starts with simple object.
Category Web Tools Category Development Tools Category Web Development Category Code Samples
( Topic last updated: 2004.01.12 09:42:14 PM )