Created
November 27, 2011 16:37
-
-
Save sebmarkbage/1397777 to your computer and use it in GitHub Desktop.
Module Syntax With Global Imports (Designed to Emulate ECMAScript 6 Modules)
This file contains hidden or 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
var two = 2, four = 4, five = 5; | |
exports: function sum(x, y) { | |
return x + y; | |
} | |
exports: var pi = 3.141593, birthday = 12; | |
exports: two, four; |
This file contains hidden or 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
imports: "Math.js"; | |
console.log(sum(two, four)); // 6 | |
console.log(five); // undefined | |
console.log(birthday); // 12 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment