Skip to content

Node JS Extra

Sandesh Kota edited this page Feb 6, 2021 · 8 revisions
  • When you create a file in Node.Js, node actually wraps the content and puts it inside a function
    • example, if you create the below file
          // index.js
          console.log('Hello');
      
    • node wraps it as below
          // index.js
          function(exports, module, require, __filename, __dirname) {
              console.log('Hello');
              return module.exports;
          }
      
    • And hence you can use these params in your function and the module.exports gets returned. also the same reason why any variable that is created in this file is not global. since it in inside a function.

Clone this wiki locally