Lets say I have a function called foo
and I want function bar
to inherit things from foo
such as:
function foo(param1, param2, param3) {
this.params = [param1, param2, param3];
this.otherParameter = 3.141;
}
module.exports = foo;
foo.prototype.getParams = function(i, bool) {
if(bool) {
return this.params[i];
}else{
return this.otherParameter;
}
};
var foo = require('./foo');
function bar() {
this.barParams = [1, 2, 3, 4];
}
How would I make bar
based off of foo
like bar.prototype = new foo(1, 2, 3);
? Should I use a bind function? If so, how?