<!DOCTYPE html>
<html>
<body>
<p id='parag' ></p>
<p id='para' ></p>
<script type="module" src="file2.js">
document.getElementById('para').innerHTML = 'hello world';
document.getElementById('parag').innerHTML = b(8,3);
</script>
</body>
</html>
file2.js :
import * as objFile1 from './file1.js';
let value = objFile1.a(5,8), value1=objFile1.b(2,5);
console.log(value,value1);
//import {a} from './file1.js';
//console.log(a(8,4));
file1.js (the one we are exporting from):
function a(x, y) { return x + y; };
const b = (w, e) => w * e;
export { a, b };