Skip to content

Instantly share code, notes, and snippets.

@chaance
Created April 7, 2021 20:43
Show Gist options
  • Save chaance/af64a38779d94c5a76cd819796049152 to your computer and use it in GitHub Desktop.
Save chaance/af64a38779d94c5a76cd819796049152 to your computer and use it in GitHub Desktop.
Node Workshop Notes

Browser JavaScript and Node overlap:

  • Browser JavaScript

    • window
    • document
    • localStorage
  • Node

    • fs
    • path
    • http
  • Both

    • Browser JS and Node JS are mostly the same with a few exceptions - mostly environment dependent
    • You can write one module (file) and use it on the server and in the browser, like a date formatter or input validator
  • Event Loop

    • JS runs in one main thread called the Event Loop
    • The event loop delegates certain slow tasks to a pool of worker threads. When the worker threads finish, they give the results of their work back to the main thread.
    • The event loop moves onto other tasks after it gives work to a worker thread. It does not wait. This helps make node fast because it is asyncronous.
  • Node isn't a language, it's a runtime called V8 for JavaScript. This just means we can run JS outside of a browser, like on a server.

  • It uses a module system called CommonJS. Or you can use an alternative called ES Modules.

  • With Node, even version numbers are Long-Term Support (LTS) versions.

  • NVM: Unofficial version manager to manage the version of Node used per project

  • NPM: Node Package Manager, install third-party dependencies (modules) using npm install <package>

  • Tooling: Node might be known as something you'd make servers with, but it's equally useful for development tooling

  • Tools like Webpack and rollup can bundle ES Modules in a way that makes them ready for the browser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment