Directory:

index.html:

<! DOCTYPEhtml>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="Width = device - width, initial - scale = 1.0" />
    <title>Document</title>
  </head>
  <body>
    <script type="module">
      import { sum } from "./index.js"
      const result = sum(1.2)
      console.log(result)
    </script>
  </body>
</html>
Copy the code

index.js:

export const sum = (a, b) = > a + b
Copy the code

Debugging interface:

Note: You need to place the web page on the node’s local server

Reference link: ponyfoo.com/articles/es…