How much JavaScript do you need to know to use Node?
By Flavio Copes
How much JavaScript do you need before learning Node.js? The core concepts to grasp first, from types and functions to closures and the event loop.
Less than you might think. You need a good grasp of the core JavaScript concepts, plus the basics of asynchronous programming. You don’t need to know every corner of the language before writing your first Node.js program.
As a beginner, it’s hard to get to a point where you are confident enough in your programming abilities.
While learning to code, you might also be confused at where does JavaScript end, and where Node.js begins, and vice versa.
Where does JavaScript end and Node begin?
The language is the same. What changes is the environment around it.
In the browser, JavaScript gets the DOM, window, cookies, and everything related to the page. Node.js has none of that. Instead it gives you modules to work with files, networking, processes, and the operating system.
So a variable, a function, or a promise works exactly the same way in both. Once you know the language, you know it everywhere. What you learn on top of it in Node is a set of APIs, not a new language.
The concepts to learn first
I would recommend you to have a good grasp of the main JavaScript concepts before starting with Node.js:
- Lexical Structure
- Expressions
- Types
- Variables
- Functions
- this
- Arrow Functions
- Loops
- Loops and Scope
- Arrays
- Template Literals
- Semicolons
- Strict Mode
- ECMAScript 6, 2016, 2017
With those concepts in mind, you are well on your road to become a proficient JavaScript developer, in both the browser and in Node.js.
Pay special attention to this and arrow functions. They come up constantly when you pass callbacks around, and they’re the source of many confusing bugs for beginners.
The asynchronous part
The following concepts are also key to understand asynchronous programming, which is one fundamental part of Node.js:
- Asynchronous programming and callbacks
- Timers
- Promises
- Async and Await
- Closures
- The Event Loop
Why does this group matter so much? Node.js is built around asynchronous I/O. Reading a file, querying a database, handling an HTTP request: all of it is non-blocking. Your code hands off the work and gets called back when it’s done.
In the browser you can write plenty of code without ever touching a promise. In Node you’ll meet callbacks and await in your very first programs, so this part of the language pays off immediately.
My advice: don’t wait until you’ve mastered the whole list. Get comfortable with the first group, understand what a callback is, then start building. The rest of the concepts will make much more sense once you meet them in real code.
Related posts about node: