The old versions of JavaScript had no import, include, or require, so many different approaches to this problem have been developed like users include JS file in webpage by including that file you can use all variables and functions of that file.
But since 2015 (ES6), JavaScript has had the ES6 modules standard to import modules in Node.js Now which is supported by most modern browsers.
Use the export
and import
Statement in JavaScript
<script type="module">
import {userAge} from './pipeline.js';
console.log(userAge)
</script>
Following code will be in the pipeline.js
export function userAge() {
var age = 25;
return age;
}