export function (export.js):
export function addTextToBody(text) {
const div = document.createElement('div');
div.textContent = text;
document.body.appendChild(div);
}
Export object (export-obj.js):
var obj = {
name:"hello",
sayOk:function(){alert("hi");}
}
export {obj}
import.html
<html>
<head>
</head>
<body>
<script type="module">
import {addTextToBody} from './export.js';
import {obj} from './export-obj.js';
addTextToBody('Modules are pretty cool.');
obj.sayOk();
</script>
</body>
</html>