Skip to content
This repository was archived by the owner on Nov 22, 2025. It is now read-only.
This repository was archived by the owner on Nov 22, 2025. It is now read-only.

Class article MUST READ #4

@mhulse

Description

@mhulse

Avoid exporting your class. Use class internally for performance gains, but export a factory that creates instances in order to discourage users from extending your class and avoid forcing callers to use new.

https://medium.com/javascript-scene/why-composition-is-harder-with-classes-c3e627dcd0aa

The above seems to argue that factory functions are preferable over exporting a class from a module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions