const sample = require('./sample.js');// if sample.js provided a function
// if sample.js provided a variable
// etc
// built-in module used for creating HTTP servers
const http = require('http');
// third-party package used for making HTTP requests
const axios = require('axios');
// sample.js
const sample = 'sample variable string';
const sample2 = 'sample2 variable string';
module.exports = sample;// importing module
const sample = require('./sample.js');
console.log(sample); // => sample variable string
console.log(sample2); // => Reference error
// sample.js
const sample = 'sample variable string';
exports.sample = sample;
// importing with ES Modules
import sample from './sample.mjs';
// within a CommonJS module
// by default .js extensionconsole.log(__filename, __dirname); // double underscore

Experience with Front-end Technologies and MERN / MEAN Stack. Working on all Major UI Frameworks like React, Angular.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store