Skip to content

Instantly share code, notes, and snippets.

@devdays
Created December 10, 2014 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devdays/3733497c97d6991fd91a to your computer and use it in GitHub Desktop.
Save devdays/3733497c97d6991fd91a to your computer and use it in GitHub Desktop.
Object JavaScript Modules - named exports
// in lib/math.js
let notExported = 'abc';
export function square(x) {
return x * x;
}
export const ONE_TWO_THREE = 123;
// in main1.js
import {square} from 'lib/math';
console.log(square(3));
// in main2.js
import as match from 'lib/math';
console.log(math.square(3));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment