JS Modules: 11. Default and named

by istiq20

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Default and Named</title>
  </head>
  <body>
    <script type="module">
      // import authorName, {content, title} from "./scripts/default-and-named.js";
      import {
        default as authorName,
        content,
        title,
      } from "./scripts/default-and-named.js";

      console.info(title); // Programmer Zaman Now
      console.info(content); // Belajar JavaScript Module
      console.info(authorName); // Eko Kurniawan Khannedy
    </script>
  </body>
</html>

JavaScript

export const title = "Programmer Zaman Now";

const content = "Belajar JavaScript Module";

const author = "Eko Kurniawan Khannedy";

export { content };
export default author;