NodeJS environment vs Browser Environment
NodeJS is run time environment of JavaScript.
Before the NodeJS only browsers can execute the JavaScript. But after the NodeJS we can run the JavaScript outside the browser. But here is few differences in Node environment and Browser environment.
In NodeJS we doesn’t have the window object because the mostly operations are related to the browser’s window. But browser environment have the default window object. Window object contains the several properties and methods to deal with the different operations on the browser window.
NodeJS has the default “global” object. Global object contains the several functions and modules to perform the server side tasks. Which we don’t need in the browser environment. But browser doesn’t have the global object. Because some of the operations in global object doesn’t required on the browser side.
In NodeJS you can control the environment. But in browser you don’t have the luxury which environment of version your browser will have. It will depends on the client browser version.
In Node we can use the latest version of ES-6–7–8–9 depends upon your node version. And to use the ES6–7–8–9 features of JavaScript we use the transpiler to transform code in ES5. Because some of the browsers doesn’t implement all those features of the ES-6–7–8–9.
In NodeJS everything is a module. It’s one of the core part of the NodeJS environment. We keep everything within a module in NodeJS and Modeling is not mandatory in client side JavaScript.
Node is headless but browsers are not headless.
Node processes request object and browsers process the response object.