I have a base class like:
Stage.js:
function Stage(name) {
this.my_name = name;
}
Stage.prototype.name = function() {
return this.my_name;
}
module.exports = Stage;
Parallel:
var Stage = require("./Stage");
ParallelStage.prototype = Stage.prototype;
ParallelStage.prototype.execute = function() {
console.log("+++ Executing stage " + this.name()+ " in parallel...");
return this;
}
function ParallelStage(name) {
Stage.call(this,name);
return this;
}
module.exports = ParallelStage;
and Serial.js:
var Stage = require("./Stage");
SerialStage.prototype = Stage.prototype;
SerialStage.prototype.execute = function() {
console.log("+++ Executing stage " + this.name()+ " in serial...");
return this;
}
function SerialStage(name) {
Stage.call(this,name);
return this;
}
module.exports = SerialStage;
However when I run:
var Parallel = require ("./ParallelStage");
var Serial = require ("./SerialStage");
var parallel = new Parallel("Extraction");
parallel.execute();
I get the following output:
+++ Executing stage Extraction in serial...
I am clearly missing something fundamental about javascript and prototype inheritance. Can someone clue me into what I am missing here? I was expecting it to show a stage execution in parallel not serial...