Skip to content

Instantly share code, notes, and snippets.

@jonnymaceachern
Last active June 20, 2016 14:37
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 jonnymaceachern/aa382a584727afcc4b46df748eda32b6 to your computer and use it in GitHub Desktop.
Save jonnymaceachern/aa382a584727afcc4b46df748eda32b6 to your computer and use it in GitHub Desktop.
module import and export examples
export default function sayHi(){
console.log('Hi');
}
import theDefaultFunction from './modules/defaultExample'; // import the default function which is sayHi()
theDefaultFunction(); // "Hi";
import { doSomething, name } from './modules/namedExport'; // when you use braces, you can import variables that you exported by name
doSomething(); // "Something"
console.log(name); // "Jonny"
// or...
import { name as firstName } from './modules/namedExport';
console.log(firstName); // "Jonny"
var name = "Jonny";
function doSomething () {
console.log("Something");
}
export {
doSomething,
name
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment