prototype1.6创建类的形式
var Animal = Class.create({ initialize: function(name, sound) { //相当如java里的构造函数 this.name = name; this.sound = sound; }, speak: function() { //成员方法 alert(this.name + " says: " + this.sound + "!"); } }); // subclassing Animal var Snake = Class.create(Animal, { initialize: function($super, name) { $super(name, 'hissssssssss'); //调用父类的构造函数 } }); var ringneck = new Snake("Ringneck"); ringneck.speak(); //-> alerts "Ringneck says: hissssssssss!" var rattlesnake = new Snake("Rattler"); rattlesnake.speak();