Other languages are imported directly and do not need to be exported, so why does es6 have such a thing?

for example, if java, wants to use which class, just import this class directly. There is no need to export in that class

Why does es6 have to export this thing? It feels troublesome and unnecessary.


java A file to introduce a file is to introduce a class
js. A file can have multiple functions. If you do not want to introduce a js file, all the functions of all classes must be exported.
set which things can be exported instead of exporting everything.


java can be imported directly, but if there are requirements for the file name, it should be consistent with the class name. No need to export is not cost-free

Menu