I currently have a hero.js
file in a directory, and it looks like this
let Person = class PersonClass {
constructor(name) {
...
class Hero {
constructor(name, level) {
...
class Mage extends Hero {
constructor(name, level, spell) {
...
Then in another file, I want to use these classes.
So I have:
require("./hero");
const manny = new Hero("Manny", 12);
const george = new Person("George");
and neither george nor manny work, they both throw Reference Error: Person/Hero is not defined
.
When I have the Person or Hero class code in the file above george and manny, they do work properly.
I want to know how to move class definitions to another file and require
them in another file.