Forum Discussion

zelot's avatar
zelot
New Contributor
8 years ago
Solved

javascript inheritance

hello,

I have a problem with inheritance using javascript. I have the following code:

file: MyFirst

class A{
  constructor(x){
  this.x = x;
  }
  
  static getA(){
    return this.x;
  } 
}

file: MySecond
var ms= require("MyFirst");
class B extends ms (ms.A doesn't work as well){
  static getB(){
    ms.A.getA();
  } 
}
module.exports.B = B;

file: Test
var ss = require("MySecond");

function firstTest(){
  ss.B.getB();
} 

and I get this error:

TypeError: class extends value [object Object] is not a function or null