So I've been using NodeJS but I have a heavy background on C and C++, and I would like to know how would I "simulate" the header effect on NodeJS.
I have the following code
foo.js
var Discord = require("discord.js");
var request = require('request');
var http = require('http');
var express = require('express');
var util = require('./dead.js');
util.beef()
then inside the other .js file
dead.js
exports.module = {
beef: function(){ request(something) }
}
I'm trying to make use of the request variable before declared inside foo.js, but it won't work because Node says it doesn't exist (so, ok it went out of scope)
- Do I have to
requireevery file I want to use in dead.js? - Would using
requireimpact the performance too much? - When is it preferable to have a long
single js file rather than have multiple ones and
requirein each one