Day 4 - Window === Global ? - Learning Node JS In 30 Days [Mini series]

Muhammad Ali (Nerdjfpb) - Dec 7 '19 - - Dev Community

Window === Global

If you know JavaScript already then you know there is a window object in console

Alt Text

If you new to JavaScript then just open your console in browser and write window there and you can see the what inside this window object

Alt Text

When we are on the Browser we can access to the window, but there is no windowin the computer. So how we can use that ?
Even after installing the npm, it doesn’t give us to access those window object so how should we do it ?

Well good thing is we can access the window here to, it just changed it’s name. It called global now.

You can go to latest doc of node js by https://nodejs.org/dist/latest-v12.x/docs/api/

Alt Text

Good thing is you can access the global object which is same as window https://nodejs.org/dist/latest-v12.x/docs/api/globals.html

Alt Text

Now you can use all the functions like – setInterval, setTimeout etc on app.js

See an example –

Alt Text

Run the code by node app.js

Alt Text

Did you understand today’s lesson ?
You can comment anytime if you’ve any question!

Originally it published on nerdjfpbblog and graphical version on instagram. you can connect with me in twitter or linkedin !

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .