JS Modules: 02. With module
by istiq20
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>With Module</title>
<script type="module" src="scripts/say.js"></script>
</head>
<body>
<script type="module">
import { sayHello, sayGoodBye, name } from "./scripts/say.js";
sayHello("Eko"); // Hello Eko
sayGoodBye("Eko"); // Good Bye Eko
console.info(name); // Eko
</script>
</body>
</html>
JavaScript
export function sayHello(name) {
console.info(`Hello ${name}`);
}
export function sayGoodBye(name) {
console.info(`Good Bye ${name}`);
}
export const name = "Eko";