Imagine writing in line to order coffee at a coffee shop. Due to the circumstances of the coffee shop, it is said that the hacker Park, who is standing in line, cannot even place an order until Kim Coding, who cam first who ordered coffee. receives the coffee he ordered. This is what we call 'blocking.' Until one task is finished, it "blocks" the next task.
Hacker Park can order coffee only after the coffee ordered by Kim Coding comes out. The time when Kim Coding's coffee order is completed and Hacker Park's coffee order start time are the same. A situation in which the start time and the completion point are the same is "synchronous." It is said:
For efficient coffee shop operation, let's change the coffee shop ordering process as follows.
Kim Coding's order completion time and Park Hacker's order start time do not need to be the same.
Even the developers who made Node.js thought the above alternative was reasonable. So we develop Node.js as a non-blocking and asynchronous runtime.
The concept of asynchronous execution in JavaScript is particularly useful in web development. In particular, the operations below must be run asynchronously to be efficient. Gotta get used to it, right?
In this unit, you will learn asynchronous flow, one of the great advantages of JavaScript. Asynchronous flow can be implemented using one of callback, promise, and async/await syntax. In this unit, we review the previously learned callback, and additionally learn promises and async/await.
You will also learn about the fs module, which allows you to read and save files with Node.js. Learn basic file reading and writing, and practice how to apply callbacks, promises, and async/await, which you will learn in the future.
By reading the example above, you can roughly understand the concepts below.