Contributions
- 21KViews0likes0Comments
how to import a javascript class
hi, I would like to import a javascript class to another file but unfortunately I couldn't successfully do that :) I tried something like this: // fileA class A{ constructor(x){ this.x = x } getX(){ return this.x } } module.exports.class = A; //fileB var ss = require("fileA"); var tt = new ss.A("2") but this doesn't work. Couldn't someone help me out ? :)Solved22KViews0likes2Comments