Last active
January 26, 2017 15:25
-
-
Save bterlson/2a7298c506db36ebb6f3 to your computer and use it in GitHub Desktop.
Module export forms have subtle differences
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// exporter1.js | |
let foo = 1; | |
export { foo as default }; // exports the foo binding | |
foo = 2; | |
// exporter2.js | |
let foo = 1; | |
export default foo; // creates a new binding named *default* and initializes it to 1. | |
foo = 2; // assigns to the foo binding which is not exported | |
// importer1.js | |
import foo from "exporter1.js"; | |
print(foo); // 2 | |
// importer2.js | |
import foo from "exporter2.js"; | |
print(foo); // 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment