Using JavaScript ES6 import/export modules
How to use ES6 modules in your browser
You can include a module in your HTML by adding a script with type="module"
:
<script type="module">
import {helloWorld} from './hello-world.js';
helloWorld();
</script>
const helloWorld = () => alert ('Hello World!');
export {
helloWorld
};
Steps:
- Download the source code and unzip the files.
- Run a static server on the source folder
eg: >live-server port=8080 - Open the localhost:8080
- You would see alert message
-
Previous
This website is made possible by displaying online advertisements to our visitors.
Please consider supporting by disabling your ad blocker.
Please consider supporting by disabling your ad blocker.
loading comments...