After some research, import/export are designed for this feature. According to the references, they're initially defined in ES6. However "This feature is not implemented in any browsers natively at this time." What's the status of this feature? Are they going to be implemented in future, or still in the state of draft?
(If you're using nodejs, Modules (https://nodejs.org/dist/latest-v5.x/docs/api/modules.html) is the best aproach)
In the current versions of JS there are a few methods of doing this. Require uses the AMD design pattern, and is the standard for frontend dependency injection / module loading. Frameworks such as Angular use this method.
Here is a link to the require docs. http://requirejs.org/