Node JS offers several Inbuilt core objects. Here we gonna discuss about one of the important Core Object - Process . The process object is a global object and can be accessed from anywhere. Here I have listed out few Methods and properties of an Object. Process Events Event: 'exit' Emitted when the process is about to exit. There is no way to prevent the exiting of the event loop at this point, and once all exit listeners have finished running the process will exit. Therefore you must only perform synchronous operations in this handler. process.on( 'exit' , function (code) { // Sync function only console .log( 'About to exit with code:' , code); }); Event: 'beforeExit' This event is emitted when node empties it's event loop and has nothing else to schedule. Normally, node exits when there is no work scheduled, but a listener for 'beforeExit' can make asynchronous calls, and cause no...
Node Module Types Node.js modules are generally categorized by 3 Types. 1. Core Modules 2. Local Modules 3. Third Party Modules Node.js Core Modules: Node.js is a light weight framework. The core modules include bare minimum functionalities of Node.js. These core modules are load automatically when Node.js process starts. However, you need to import the core module first in order to use it in your application. Loading Core Modules: In order to use Node.js core or NPM modules, you first need to import it using require() function as shown below. var module = require('module_name'); As per above syntax, specify the module name in the require() function. The require() function will return an object, function, property or any other JavaScript type, depending on what the specified module returns. Node.js Local Module: Local modules are modules created locally in your Node.j...