* There are 3 ways to use asynchronous in nodejs: callback, promises, async/await
1. Callbacks functions
- Callbacks are functions that are passed as arguments to other functions and are executed when the operation completes.
- Callbacks are commonly used to handle asynchronous operations.
* function(err, data): is callback (is the second parameter of readFile() method)
2. Promises
- Promises represent a value that may not be avaiable
* (data) is promises (is return by method readFile())
3. Async/await syntax
- Async/await is a syntax allows to write asynchronous code that looks and behaves like synchronous code
Thank you

No comments:
Post a Comment