When working with Java, there are 4 different visibility levels to consider. In addition to the commonly known public
and private
levels, there is also the protected
level and what is referred to as the "default" or "package-local" level.
Modifier | Class | Package | Subclass | World |
---|---|---|---|---|
public | Y | Y | Y | Y |
protected | Y | Y | Y | X |
no modifier | Y | Y | X | X |
private | Y | X | X | X |
For more information on Java access level comparisons, visit:
In my JavaScript projects, I find myself needing a similar "package-private" level of visibility. Are there any equivalents for this in JavaScript modules?
Currently, while developing a library (which will eventually be published as an NPM package), I am looking for a way to export
certain functions or classes internally within the module, without them being part of the public API intended for consumer use.