With ES6, you are able to make “actual” classes just like this:
class Animal {
constructor(name) {
this.name = name;
}
print() {
console.log('Name is :' + this.name);
}
}
You can export a class just like anything else:
module.exports = class Animal {
};
Once imported into another module, then you can treat it as if it were defined in that file:
var Animal = require('./Animal');
class Cat extends Animal {
...
}