import js file in js code example
Example 1: import js in html
<script type="text/javascript" src="yourfile.js"></script>
Example 2: include other js files in a js file
document.writeln("<script type='text/javascript' src='Script1.js'></script>");
document.writeln("<script type='text/javascript' src='Script2.js'></script>");
Example 3: javascript using another js file
export function hello() {
return "Hello";
}
import {hello} from 'module';
let val = hello();
Example 4: javascript import
import { module } from "./path";
import Module from "./path";
import Module, { module } from "./path";
Example 5: javascript include a js file from another
$.getScript('/path/to/imported/script.js', function()
{
});
Example 6: how to call a script from another script in javascript
<script type="text/javascript" src="file1.js"></script>
<script type="text/javascript" src="file2.js"></script>
<script type="text/javascript">
alertOne( );
</script>