Difference between Browser JavaScript and Node.js

Screenshot 2022-08-16 at 11.41.55 AM.png

Node.js does not have:

  1. When working on Node.js you have no access to browser APIs(like DOM, fetch, etc).
  2. Because we build serverside apps with node.
  3. Node apps will have pure logic without the graphical interface.

Node.js does have:

  1. Access to filesystem. Info about the operating system, etc.
  2. It is based on versions. So, unlike browser apps which depends on users browser, our node app runs only in the node js version it was built on.
  3. Unlike in browser where modules are optional, in Node.js you have access to modules by default.
  4. Under the hood Node.js uses commonJS for libraries.

Example: In terminal

Screenshot 2022-08-16 at 11.55.55 AM.png

Exmaple: In js file

Screenshot 2022-08-16 at 12.00.38 PM.png

Screenshot 2022-08-16 at 12.01.01 PM.png