Lucan Lucan - 1 year ago 125
Node.js Question

import and export in Javascript

According to this question Include a JavaScript file in another JavaScript file?. It seems a lots of people are interested in breaking big Javascript projects into small modules and export/import modules for code reuse.

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 ( is the best aproach)


Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download