| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Statements/export | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2018 ..
export , ( ).
: , , Traceur Compiler, Babel or Rollup.
export { name1, name2, , nameN };
export { variable1 as name1, variable2 as name2, , nameN };
export let name1, name2, , nameN; // var
export let name1 = , name2 = , , nameN; // var, const
export default ;
export default function () { } // class, function*
export default function name1() { } // class, function*
export { name1 as default, };
export * from ;
export { name1, name2, , nameN } from ;
export { import1 as name1, import2 as name2, , nameN } from ;
, :
:
export { myFunction }; //
export const foo = Math.sqrt(2); //
( ) ( ):
export default function () {} // 'export default class {}'
//
. , , .
(default), (). , , - . "", .
:
// "my-module.js"
function cube(x) {
return x * x * x;
}
const foo = Math.PI + Math.SQRT2;
export { cube, foo };
(. import) :
import { cube, foo } from "my-module";
console.log(cube(3)); // 27
console.log(foo); // 4.555806215962888
(fallback) , export default.
// "my-module.js"
export default function cube(x) {
return x * x * x;
}
, :
import cube from "my-module";
console.log(cube(3)); // 27
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-exports |
importThis page was last modified on 17 . 2024 . by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |