importing js file code example
Example 1: node import all functions from file
function connect() {
}
function closeConnection() {
}
module.exports = {
connect(),
closeConnection()
};
const DbHelper = require ('./utils/dbHelper');
DbHelper.connect();
const { connect, closeConnection } = require ('./utils/dbHelper');
connect();
Example 2: javascript using another js file
export function hello() {
return "Hello";
}
import {hello} from 'module';
let val = hello();
Example 3: How to add js file to a site through url
var jsFile = document.createElement("script");
jsFile.src = "homePage.js";
document.body.appendChild(jsFile);