Node.js global objects are global in nature and available in all modules.

You don't need to include these objects in your application; rather they can be used directly. These objects are modules, functions, strings and object etc.





This built-in object is used to print stdout and stderr.


A reference to the module.exports that is shorter to type. exports isn't actually a global but rather local to each module.


A process object is a global object, which provides interaction with the current Node process and can be accessed from anywhere.


The require() function is a built-in function, and used to include other modules that exist in separate files, a string specifying the module to load. It accepts a single argument. It is not global but rather local to each module.

setImmediate(callback[, ...args])

setInterval(callback, delay[, ...args])

setTimeout(callback, delay[, ...args])

Class: Buffer


It is a string. It specifies the name of the directory that currently contains the code.


It specifies the filename of the code being executed. This is the resolved absolute path of this code file. The value inside a module is the path to that module file.

Process Methods:

The process object is used to get the information on current process. It provides multiple events and methods related to the process activities.

Using these methods, we can get the better control over system interactions.

The following are some of the Process methods which are frequently used in the application.

abort() :

abort() method is used to cause the node to emit an abort which results in the node to exit and generate a core file.


chdir() method is used to change the current working directory of the process or throws an exception upon failure.

cwd ()

cwd () method is used to return the current working directory of the process.


exit([code]) method is used to end the process with the specified code. If it is omitted then exit uses the ‘success’ code 0.

kill(pid[, signal])

kill(pid[, signal]) method is used to send a signal to a process. pid is the process id and signal is the string describing the signal to send.


memoryUsage() method is used to return an object describing the memory usage of the Node process which is measured in terms of bytes.


nextTick(callback) the completion of the current event loop it turns to call the callback function.


uptime() method is used to return the number of seconds for which the Node has been running.


console.log() is used to print to stdout with a newline. We can pass multiple arguments. Let's see the different variations of console.log in the example given below :


This method is used to clear the console. Clearing the console can be useful while dealing with a big program in which you are logging a lot of stuff and while performing debugging , you want to see output after a certain point. For e.g. in the snippet below we are printing the value which changes in the program so we will clear the previous values from the console and see only the final value in the end. This is a very simple example of how console.clear method can be used.


This module is used to maintains an internal label and output to stdout the number of times console.count() is called with any particular label. For e.g. in the snippet below labels are default , remo and rj whose occurrences are printed in the console. The default label is default .


This method is used to reset the counter for a particular label internally.By default it will decrement default .


This method is used to print to stderr . We can pass multiple arguments where first argument is primary and remaining arguments are substitution values. Snippet is given below.


console.time method is used to start a timer which can be used to compute the duration of the operation. Each timer is identified using unique label .


We use the same label while calling console.timeEnd method which is used to stop the timer. Time is printed in milliseconds on stdout by console.timeEnd() method.


This method is similar to console.error and is used to print to stderr .

About Author

Article is written by Pavan (a) KarthiQ. Well, I am serving notice period in an MNC, Bangalore. I thought to enrich every person knowledge a little, I always have a feeling, when we teach something, we will learn more than what you know. Knowledge is the only thing that doubles when you spend it.

I have also created the reporter for Protractor Jasmine. Use for your projects without any hesitation

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions