Fast way to create subclass

Suppose I have:

// ---------- CALL PARENT METHODS ----------
function Vehicle(name) {
this.name = "Vehicle"
}

// Functions for the parent object
Vehicle.prototype = {
drive: function(){
return this.name + " drives forward";
},
stop: function(){
return this.name + " stops";
}
}

And now I want to create the subclasses:  Truck, Car, and Motorcycle.  Is there a fast way to do this in webstorm? 

For example:


function Truck(name) {
this.name = name
}

// Inherit from Vehicle
Truck.prototype = new Vehicle();
Truck.prototype.constructor = Truck;

// Overwrite drive parent method
Truck.prototype.drive = function(){

// Call the parent method with apply so that the parent
// method can access the Trucks name value
var driveMsg = Vehicle.prototype.drive.apply(this);
return driveMsg += " through a field";
}

Is there any kind of auto-generate this command?

 

0

No, there is no such feature; if you miss it, please feel free to create a feature request in youtrack, https://youtrack.jetbrains.com/issues/WEB

0

请先登录再写评论。