Forum Discussion

zelot's avatar
New Contributor
7 years ago

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...
  • KSQian's avatar
    7 years ago

    I was trying to answer a JavaScript question but accidentally committed sin. I apologize :( 


    For OP: Below is how I'd export and require.


    //file 1
    class Foo {
    module.exports = Foo
    //file 2 
    const Foo = require('file1')
    class Bar extends Foo {