Last active
June 20, 2016 14:37
-
-
Save jonnymaceachern/aa382a584727afcc4b46df748eda32b6 to your computer and use it in GitHub Desktop.
module import and export examples
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
export default function sayHi(){ | |
console.log('Hi'); | |
} |
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
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" |
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
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