Created
September 3, 2019 21:42
-
-
Save masautt/a852fda69525b9671ba6a86df9a822cb to your computer and use it in GitHub Desktop.
How can I include a JavaScript file in another JavaScript file?
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
// EXPORTING A DEFAULT | |
// separateFile.js | |
export default function foo() { | |
console.log("bar"); | |
} | |
// index.js | |
import foo from "./separateFile" | |
foo(); //--> "bar" | |
/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
//EXPORTING WITHOUT SETTING A DEFAULT | |
//seperateFile.js | |
export function foo() { | |
console.log("bar"); | |
} | |
// index.js | |
import {foo} from "./separateFile" | |
foo(); //--> "bar" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment