How To Import One Javascript File Into Another Code Example


Example 1: 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 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";

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable