Imagine I have this class:
class Class { constructor(arg1, arg2) { arg1 = arg2}; } Should I do this?
class Class = exports.Class { constructor(arg1, arg2) { arg1 = arg2}; } Or there's another way?
With export syntax, just put export before the class:
export class Class { (this results in a named export named Class)
Or, for a default export:
export default class Class { With module syntax, assign to module.exports, or to a property of module.exports:
module.exports = class Class { or
module.exports.Class = class Class { extern, public and private? So all the members are public?# syntax. Still, it's easy to make private instance variables with a WeakMap indexed by thisWeakMap, and a similar implementation may be added to the language laterYou should do like this (for other ways, check @Snow answer):
class Class { constructor(arg1, arg2) { arg1 = arg2}; } module.exports = Class;
class Class = exports.Class {is a syntax error. You shouldn't write syntax errors.