In this video we are going to learn about Global Object.
Node.js global objects are global in nature and they are available in all modules.
We do not need to include these objects in our application rather we can use them directly.
These objects are modules, functions, strings and object itself.
So lets see some goble object.
First lets see console global object.
Console is used to print different levels of messages.
There are built-in methods to be used for printing informational, warning, and error messages.
So lets use the console global object.
So inside the index.js file just write here

conole.log(\"Hello World!\");

Now save and run this.
So switch to the command prompt and run the command.

node index.js

You can see the Hello world! message on console.
Now lets see another global object which is __filename.
The __filename represents the filename of the code being executed.
This is the resolved absolute path of the code file.
Lets see how can we use this.
Go to the index.js file and just write the follows.


It will print absolute path of this file.
Now switch to command prompt and here.
Just re-run, You can see the absolute path of the index.js file.
Alright Now lets see the __dirname global object.
The __dirname represents the name of the directory that the currently executing script resides in.
So in index.js file just write


And now re-run the index.js file.
You will get the full path of the directory.

Now let see the setTimeout global object.
setTimeout(cb, ms) global function is used to run callback function after at given milliseconds.
So lets see how can we use setTimeout.
So go to the index.js file and here lets create a function and call this function inside the setTimeout.

public function sayHello(){

Here 1000 is millisecond. 1000 millisecond is equal to 1 second ok.
Now lets check, So just re-run the index.js file.
And you can see here after 1 second hello is printing continiously.
Now next global object is setInterval() setInterval global object is used to run callback function repeatedly after given time interval.
Lets see the setinterval jus type here.


Now lets check, so just re-run the index.js file and you can see here the result.
Hello text is printing continuously after 1 second ok.
Now Lets see the clearTimeout.
clearTimeout(t) global function is used to stop a timer.
Go to the index.js file write the following code for using clearInterval.

var time=1;
var timer = setInterval(function(){

So lets check so re-run the index.js file.
It will print Hello 5 times.
After 5 second it stopped the timer.
So in this way global object in nodejs.