This is a new technology, part of the ECMAScript 2015 (ES6) standard .
This technology's specification has been finalized, but check the compatibility table for usage and implementation status in various browsers.
The following content does not reflect the final state of the ECMAScript 6 modules specification. For more accurate documentation, see ECMAScript 6 modules: the final syntax.
The export statement is used to allow a signed script to provide properties, functions, and objects to other signed or unsigned scripts. It is an ancient Netscape 4 feature that has been removed in Firefox 3.5 (bug 447713). A new export declaration is specified by ECMAScript 2015 modules.
Syntax
Example 1: export name1, name2, ..., nameN; Example 2: export *;
nameN- Property, function, or object to be exported.
Description
Typically, information in a signed script is available only to scripts signed by the same principals. By exporting properties, functions, or objects, a signed script makes this information available to any script (signed or unsigned). The receiving script uses the companion import statement to access the information.
Example 1 shows the syntax for exporting specified properties, functions, and objects.
Example 2 shows the syntax for exporting all the properties, functions, and objects from the script.
Specifications
| Specification | Status | Comment |
|---|---|---|
| ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Imports' in that specification. |
Standard | Initial definition. |
Browser compatibility
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | Not supported | Not supported | Not supported | Not supported | Not supported |
| Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Basic support | Not supported | Not supported | Not supported | Not supported | Not supported | Not supported |