Created
November 1, 2018 18:05
-
-
Save biswajitpaul01/fa1ca25574f82d24df0057332a9ab049 to your computer and use it in GitHub Desktop.
Javascript Import Export
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Javascript Import Export Module Example</title> | |
</head> | |
<body> | |
<script type="module"> | |
import { square, diag } from './assets/js/lib.js'; | |
console.log("Square: " + square(11)); | |
</script> | |
<script type="module" src="assets/js/main.js"></script> | |
</body> | |
</html> |
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
export const sqrt = Math.sqrt; | |
export function square(x) { | |
return x * x; | |
} | |
export function diag(x, y) { | |
return sqrt(square(x) + square(y)); | |
} |
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
import { square, diag } from './lib.js'; | |
console.log(square(11)); | |
console.log(diag(4, 3)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment