Node vs Browser Javascript

Node vs Browser Javascript

1. Node vs Browser JS Globals

Node has access to some common JS globals like console, setTimeOut, etc., and other Node-specific globals like process, require and __dirname.

JS in the browser has access to common JS globals as well, and some browser-specific ones like location, window, and document queries.

2. Node vs Browser JS Execution

NodeJS is a runtime to run JS scripts locally. NodeJS runs code on your local machine, and has access to everything a regular programming language has. It's no different to running C code or BASH scripts on your machine.

Running JS on your browser is very different to running it on Node. It runs in a sandbox in your browser with very limited access to your computer's resources. It has no access to your local filesystem, and can't run commands locally. However, you have access to the DOM and limited access to the browser's state.

For other web dev infographics, check out this page

Infographics
React Performance TipsReact Performance Tips1. useRef vs useStatePrefer using useRef over useState when you don’t want the component to rerender on each change. 2. useCallback vs inline functionsYou should wrap inline functions in a useCallback, especially when you’re passing them down as props to c…

Follow me on Twitter @thewritingdev