JS Modules: 06. Alias di Export

by istiq20

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Alias di Export</title>
  </head>
  <body>
    <script type="module">
      import { perusahaan, total, Perusahaan } from "./scripts/multiple2.js";

      console.info(perusahaan); // Programmer Zaman Now
      console.info(total(10, 10)); // 20

      const a = new Perusahaan();
      console.log(a); // Company {}
    </script>
  </body>
</html>

JavaScript

const company = "Programmer Zaman Now";

function sum(first, second) {
  return first + second;
}

class Company {}

export { company as perusahaan, sum as total, Company as Perusahaan };