Skip to content

Instantly share code, notes, and snippets.

@wilk
Created July 17, 2015 06:12
Show Gist options
  • Save wilk/70980956f4c77cc9d120 to your computer and use it in GitHub Desktop.
Save wilk/70980956f4c77cc9d120 to your computer and use it in GitHub Desktop.
ES6 Module
// file js/myModule.js
export function sum(x, y) {return x + y}
export const ADDENDUM = 10
// file yourModule.js
import * as myModule from "js/myModule"
import {sum, ADDENDUM} from "js/myModule"
console.log(myModule.sum(10, 20)) // 30
console.log(sum(ADDENDUM, ADDENDUM)) // 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment