Given this module module-name:

// module-name.js
export default function foo(){ console.log("foo");}
export function bar(){ console.log("bar");}
console.log("hello world");

Consider the following cases which have been tested in node.js v9.11.1 using the command node --experimental-modules some-importer.mjs:


Importing the default export

// import defaultExport from "module-name";
import fizzbuzz from "module-name";

Only the default export will be available thus:

  • fizzbuzz (which is foo) is available
  • bar is not available
  • console.log(hello world) will have been run

Importing all exports using * wildcard

import * as name from "module-name";

All exports are available but attached to an Object identified as name:

  • foo is not available
  • bar is not available
  • name.foo is not available (though you think it would be)
  • name.bar is available
  • console.log(hello world) will have been run

Importing an identified export

// import { export } from "module-name";
import { bar } from "module-name"

Only the identified export is available:

  • foo is not available
  • bar is available
  • console.log(hello world) will have been run

Importing an identified export as an alias

// import { export as alias } from "module-name";
import { bar as mybar } from "module-name";

Only the identified export is available and only as the identified alias:

  • foo is not available
  • bar is not available
  • mybar (which is bar) is available
  • console.log(hello world) will have been run

Importing the default export and using the * wildcard

// import defaultExport, * as name from "module-name";
import fizzbuzz, * as name from "module-name";

The default item from the module can be referenced as defaultExport and all other exported items are attached to name

  • fizzbuzz (which is foo) is available
  • bar is not available
  • name.bar is available
  • console.log(hello world) will have been run

No actual identified imports

import "module-name";

The module is loaded, but nothing is actually available in the module that imported. This means that file runs but nothing is exposed

  • foo is not available
  • bar is not available
  • console.log(hello world) will have been run
Answer from zero298 on Stack Overflow
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript
JavaScript - MDN Web Docs - Mozilla
May 22, 2026 - JavaScript (JS) is a lightweight interpreted (or just-in-time compiled) programming language with first-class functions. While it is most well-known as the scripting language for Web pages, many non-browser environments also use it, such as Node.js, Apache CouchDB and Adobe Acrobat.
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Modules
JavaScript modules - MDN Web Docs - Mozilla
There is also a type of export called the default export — this is designed to make it easy to have a default function provided by a module, and also helps JavaScript modules to interoperate with existing CommonJS and AMD module systems (as explained nicely in ES6 In Depth: Modules by Jason Orendorff; search for "Default exports").
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Classes
Classes - JavaScript - MDN Web Docs
May 22, 2026 - ES6 In Depth: Classes on hacks.mozilla.org (2015) Was this page helpful to you? Yes · No Learn how to contribute · This page was last modified on May 22, 2026 by MDN contributors.
🌐
Tania's Website
taniarascia.com › es6 syntax and feature overview
ES6 Syntax and Feature Overview | Tania Rascia's Website
April 9, 2018 - ES6 · let x = 0 · MDN Reference: let · ES6 introduced the const keyword, which cannot be redeclared or reassigned, but is not immutable. ES6 · const CONST_IDENTIFIER = 0 // constants are uppercase by convention · MDN Reference: const · ...
🌐
GitHub
github.com › lukehoban › es6features › blob › master › README.md
es6features/README.md at master · lukehoban/es6features
More info: MDN Symbol · In ES6, built-ins like Array, Date and DOM Elements can be subclassed. Object construction for a function named Ctor now uses two-phases (both virtually dispatched): Call Ctor[@@create] to allocate the object, installing any special behavior ·
Author   lukehoban
Top answer
1 of 2
4

Given this module module-name:

// module-name.js
export default function foo(){ console.log("foo");}
export function bar(){ console.log("bar");}
console.log("hello world");

Consider the following cases which have been tested in node.js v9.11.1 using the command node --experimental-modules some-importer.mjs:


Importing the default export

// import defaultExport from "module-name";
import fizzbuzz from "module-name";

Only the default export will be available thus:

  • fizzbuzz (which is foo) is available
  • bar is not available
  • console.log(hello world) will have been run

Importing all exports using * wildcard

import * as name from "module-name";

All exports are available but attached to an Object identified as name:

  • foo is not available
  • bar is not available
  • name.foo is not available (though you think it would be)
  • name.bar is available
  • console.log(hello world) will have been run

Importing an identified export

// import { export } from "module-name";
import { bar } from "module-name"

Only the identified export is available:

  • foo is not available
  • bar is available
  • console.log(hello world) will have been run

Importing an identified export as an alias

// import { export as alias } from "module-name";
import { bar as mybar } from "module-name";

Only the identified export is available and only as the identified alias:

  • foo is not available
  • bar is not available
  • mybar (which is bar) is available
  • console.log(hello world) will have been run

Importing the default export and using the * wildcard

// import defaultExport, * as name from "module-name";
import fizzbuzz, * as name from "module-name";

The default item from the module can be referenced as defaultExport and all other exported items are attached to name

  • fizzbuzz (which is foo) is available
  • bar is not available
  • name.bar is available
  • console.log(hello world) will have been run

No actual identified imports

import "module-name";

The module is loaded, but nothing is actually available in the module that imported. This means that file runs but nothing is exposed

  • foo is not available
  • bar is not available
  • console.log(hello world) will have been run
2 of 2
0

how is name different from defaultExport?

name is an object that holds all the exported values as exported key/values, except for the default export, which will be in defaultExport. If you would export the following from a file:

export default function main() {}
export function helper1() {}
export function helper2() {}

Then you could import main as the default import:

import main from "file";

That won't import the helpers. For that you would use * as:

import * as helpers from "file";
helpers.helper1();

And then if we import, how would we attach variable to it?

They get attached to the same name they were exported with, so to only import one of the above helpers:

import { helper1 } from "file";
helper1();

If you want to rename that import because it is missleading / clashing, then the as syntax comes in:

import { helper1 as someOther } from "file";
someOther();
🌐
Unibo
lia.disi.unibo.it › materiale › JS › developer.mozilla.org › en-US › docs › Web › JavaScript › New_in_JavaScript › ECMAScript_6_support_in_Mozilla.html
ECMAScript 6 support in Mozilla - JavaScript | MDN
ECMAScript 6 is the next version of the standard, code-named "ES.next". Specification drafts can be found on the official ECMA wiki. The first working draft based on ECMAScript 5.1, was published on July 12, 2011 as "ES.next".
Find elsewhere
🌐
GitHub
github.com › lukehoban › es6features
GitHub - lukehoban/es6features: Overview of ECMAScript 6 features · GitHub
More info: MDN Symbol · In ES6, built-ins like Array, Date and DOM Elements can be subclassed. Object construction for a function named Ctor now uses two-phases (both virtually dispatched): Call Ctor[@@create] to allocate the object, installing any special behavior ·
Author   lukehoban
🌐
Sophiali
sophiali.dev › modern-javascript-es6
Modern JavaScript: ES6 and Beyond - Sophia Li
MDN reference: try...catch · And there we have it! You now know how to use a lot of commonly used ES6+ JavaScript features. Test your JavaScript knowledge with some JavaScript questions by Lydia Hallie. How to Use the JavaScript Fetch API to Get Data from the NASA APOD API ·
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › JavaScript_technologies_overview
JavaScript technologies overview - JavaScript | MDN
ES6 is synonymous with ES2015. ESNext is a dynamic name that refers to whatever the next version is at the time of writing.
🌐
DEV Community
dev.to › codingcrafts › javascript-es6-features-every-developer-should-know-12ak
JavaScript ES6 Features Every Developer Should Know. - DEV Community
September 4, 2024 - In conclusion, the integration of JavaScript ES6 features is central to our software development process at Coding Crafts. We believe in staying at the forefront of technology and continually enhancing our development practices to provide efficient, innovative, and highly functional software solutions for our clients. We invite you to partner with us and experience the power of cutting-edge software development from one of the Best IT Company in USA. MDN Web Docs - JavaScript Exploring ES6 by Dr.
🌐
The Odin Project
theodinproject.com › lessons › javascript-es6-modules
ES6 Modules | The Odin Project
As per usual, you can learn most about JavaScript keywords and concepts from the MDN docs, so check out the docs on export and docs on import. There are little extras about them we have not covered in this lesson, such as aliases and namespace imports. The following questions are an opportunity to reflect on key topics in this lesson. If you can’t answer a question, click on it to review the material, but keep in mind you are not expected to memorize or master this knowledge. Before ES6 modules, how would you privatize a variable from being accessible in other files?
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Operators › Spread_syntax
Spread syntax (...) - JavaScript - MDN Web Docs - Mozilla
May 22, 2026 - The spread (...) syntax allows an iterable, such as an array or string, to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected. In an object literal, the spread syntax enumerates the properties of an object and adds the key-value ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Functions › Arrow_functions
Arrow function expressions - JavaScript - MDN Web Docs
ES6 In Depth: Arrow functions on hacks.mozilla.org (2015) Was this page helpful to you? Yes · No Learn how to contribute · This page was last modified on Feb 21, 2026 by MDN contributors.
🌐
Robkendal
robkendal.co.uk › blog › how-to-use-arrow-functions-in-javascript-es6
How to use arrow functions in JavaScript ES6 - Rob Kendal
January 2, 2019 - Arrow functions (as per the MDN reference guide on arrow functions ) are simply function statements with shorter syntaxes; they offer an alternative to the standard function construct, function (args) { // code stuff here; } and their primary advantage is in creating code clarity.
🌐
Mozilla Hacks
hacks.mozilla.org › home › articles › es6 in depth: an introduction
ES6 In Depth: An Introduction – Mozilla Hacks - the Web developer blog
April 24, 2015 - ES6 is a major upgrade to the language. At the same time, your JS code will continue to work. ES6 was designed for maximum compatibility with existing code. In fact, many browsers already support various ES6 features, and implementation efforts ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Template_literals
Template literals (Template strings) - JavaScript | MDN
function template(strings, ...keys) { return (...values) => { const dict = values[values.length - 1] || {}; const result = [strings[0]]; keys.forEach((key, i) => { const value = Number.isInteger(key) ? values[key] : dict[key]; result.push(value, strings[i + 1]); }); return result.join(""); }; } const t1Closure = template`${0}${1}${0}!`; // const t1Closure = template(["","","","!"],0,1,0); t1Closure("Y", "A"); // "YAY!" const t2Closure = template`${0} ${"foo"}!`; // const t2Closure = template([""," ","!"],0,"foo"); t2Closure("Hello", { foo: "World" }); // "Hello World!" const t3Closure = template`I'm ${"name"}. I'm almost ${"age"} years old.`; // const t3Closure = template(["I'm ", ". I'm almost ", " years old."], "name", "age"); t3Closure("foo", { name: "MDN", age: 30 }); // "I'm MDN.
🌐
Mozilla Hacks
hacks.mozilla.org › home › articles › es6 in depth: modules
ES6 In Depth: Modules – Mozilla Hacks - the Web developer blog
August 14, 2015 - This shorthand is equivalent to import {default as _} from "lodash";. All CommonJS and AMD modules are presented to ES6 as having a default export, which is the same thing that you would get if you asked require() for that module—that is, the ...