how to import a script in javascript code example

Example 1: import script html

<html>
  <head>
    <script type="text/javascript" src="/path/to/script.js"></script>
    ...

Example 2: javascript using another js file

// module.js
export function hello() {
  return "Hello";
}

// main.js
import {hello} from 'module'; // or './module'
let val = hello(); // val is "Hello";

Example 3: import javascript

/*Imagine a file called math_functions.js that contains several functions
related to mathematical operations. One of them is stored in a variable called
add.*/

//If you want to import one item:
import { add } from './math_functions.js';

//If you want to import multiple items:
import { add, someothervariable } from './math_functions.js';