Window === Global
If you know JavaScript already then you know there is a window object in console
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
When we are on the Browser we can access to the window, but there is no window in 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/
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
Now you can use all the functions like – setInterval, setTimeout etc on app.js
See an example –
Run the code by node app.js
Did you understand today’s lesson ?
You can comment anytime if you’ve any question!