Syntax

JavaScript Export from a Module Syntax

In JavaScript, export from a module: makes a value available to other modules — export function add(a, b) { ... }

Quick Answer

Syntax
export function add(a, b) { ... }
JavaScriptSyntax

Export from a Module

Code example
export function add(a, b) { ... }

Makes a value available to other modules.

Learn More

How to export from a module in JavaScript

  1. Open your JavaScript file or editor.
  2. Copy the example, then replace its sample names and values for your code.

JavaScript Export from a Module Syntax

Use export function add(a, b) { ... }.

Related Syntax References

Frequently asked questions

What is the JavaScript syntax for export from a module?

Use this pattern: export function add(a, b) { ... }

Can I copy this JavaScript code example?

Yes. Use Copy code and adapt the example to your program.

Is this JavaScript syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify