Wiltech Blog
Welcome to Wiltech's code space, where we learn what we love and love what we learn!
Software Development | The latest technology trends | Tutorials & more
How To Start Learning Node.js
March 13, 2023
Richard Wilson
For most people the hardest part of doing anything is often making that first step. This blog post will help guide you on how to get started with learning to code.
Beginner
Nodejs
Coding
If you think learning Node.js might be your next step in advancing your career, you’ll find advice for getting started below.
1. Learn JavaScript
Node is written in JavaScript, so you should start by learning JavaScript. This means understanding scopes, functions, closures, module patterns, classes, promises, and callbacks, as well as the capabilities of Strings, Numbers, Arrays, Objects, Sets, and Maps.
2. Understand Why It Is Called Node
When you know why it is called Node, you’ll better understand how it works. It’s called Node because it is used to build simple single-process blocks called nodes. These nodes can be organized with good networking protocols for communication with each other and be scaled up to build large distributed programs.
3. Understand non-blocking in Node
This is the main feature of Node. You need to understand how I/O operations in Node are performed asynchronously, with the lines of code adhering to a non blocking pattern
- Give Node instructions (a function) to execute.
- Give the function some arguments.
- Give Node a callback with your function.
- Node will proceed to take instructions from other lines after yours.
- When your function has been computed, Node will call your callback with the result of the computation.
4. Learn the Concept of the Event Loop
Basically, there is a stack, a heap, and a queue. In a loop, the queue is polled for the next message and when a message is encountered, the callback for that message is executed. For more on this process and an illustration of the loop, check out this explanation from the Carbon Five blog.
5. Learn the Global Variables
To see all the options, type global in a Node REPL (read-eval-print-loop) and type global. You will see JavaScript, Node library functions, and Node global objects. Learn the various tasks that you can use them for.
6. Learn How to Use the Libraries That Come With Node
You can use the libraries to figure out how to run a tcp server and program sockets using “net,” how to read/write files with “fs,” or how to run a streaming-ready web server with “http” among many more tasks.
7. Learn Code Writing for Node
Read and try to understand some of the codes on a framework like “Express.” Reading in a group makes it even easier.
8. Without Using Any Frameworks, Write a Web Application on Node
Handle as many cases as you can until you are comfortable using Node.