public technically does nothing as a visibility modifier (all members of the class are public by default); it exists as an explicit analogue of private . This right is only within classes.
export does two different things depending on its context (in a top-level element in a file or in a module block).
At the top level of the file, export means that the containing file is an external module (i.e., it will be loaded using the RequireJS command, Node require or some other CommonJS / AMD compatible bootloader) and that the character you put export on must be an exported member of this external module.
Inside the module export block means that the specified element is visible outside this module. By default, the objects in the module blocks are “privacy closure” - objects that do not have visibility are not visible outside the module. When the declaration inside the module has the export modifier, it instead becomes a property of the module object, which can be accessed from outside the module.
There is no place in the language where both public and export are legal, so the choice is relatively simple in this regard.
source share