I have the next code with inheritance.
function FileS(){}
FileS.prototype.getS = function (num){
console.log(num);
}
FileS.prototype.getDynamic = function(){
// WHAT I need to write here, so the function would call the DYNAMIC function
}
S3.prototype= new Files();
S3.prototype.constructor = S3();
function S3(){}
S3.prototype.getS = function (num){
console.log("This is for S3: " + num);
}
function dataE(u){
var s3 = new S3();
s3.getDynamic();
}
As I understand, s3 will call to FileS.protortpe.getDynamic, because it hasn't this function in S3 prototype. But now, I want that FileS.protortpe.getDynamic will call to s3.protortpe.getS, if the type is S3, and FileS.prototype.getS otherwise. How can I do it (without specify s3 or FileS, because that is more types..)?
S3.prototype.constructor = S3();. You want to assign a reference to the function, not an instance or return value.new Filesto createS3's prototype is an anti-pattern.