DEV Community

Discussion on: Splitting Javascript Classes Into Different Files

Collapse
 
joelnet profile image
JavaScript Joel

If you are going this far, then you don't even need the class.

this:

class Animal {}

is the same as:

function Animal() { }

This is basically how classes were created prior to ES6.

You could use Object.assign to assign multiple functions at the same time:

function Animal() { }

Object.assign(Animal.prototype, { noise, name, move })