Skip to content

Commit d0efde4

Browse files
Merge pull request learning-zone#14 from rahulpandey70/master
Added answer for question number 79 and 80.
2 parents 8105c4e + 2c91d2c commit d0efde4

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@
8787
| 76. |[How to Implement Memcached in Nodejs?](#q-how-to-implement-memcached-in-nodejs)|
8888
| 77. |[Explain Error Handling approaches in Nodejs?](#q-explain-error-handling-approaches-in-nodejs)|
8989
| 78. |[How to generate and verify checksum of the given string in Nodejs](#q-how-to-generate-and-verify-checksum-of-the-given-string-in-nodejs)|
90+
| 79. |[What is Callback function in node.js?](#q-what-is-callback-function-in-nodejs)|
91+
| 80. |[What is asynchronous programming in node.js?](#q-what-is-asynchronous-programming-in-nodejs)|
9092

9193
<br/>
9294

@@ -386,7 +388,19 @@ Core modules can also be identified using the ```node:``` prefix, in which case
386388

387389
## Q. ***What is callback function in Node.js?***
388390

389-
*ToDo*
391+
In node.js, we basically use callbacks for handling asynchronous operations like — making any I/O request, database operations or calling an API to fetch some data. Callback allows our code to not get blocked when a process is taking a long time.
392+
393+
```javascript
394+
function myNew(next){
395+
console.log("Im the one who initates callback");
396+
next("nope", "success");
397+
}
398+
399+
myNew(function(err, res){
400+
console.log("I got back from callback",err, res);
401+
});
402+
```
403+
390404

391405
<div align="right">
392406
<b><a href="#">↥ back to top</a></b>
@@ -826,7 +840,7 @@ $ node
826840

827841
## Q. ***What is asynchronous programming in Node.js?***
828842

829-
*ToDo*
843+
Asynchronous programming is a form of parallel programming that allows a unit of work to run separately from the primary application thread. When the work is complete, it notifies the main thread (as well as whether the work was completed or failed). There are numerous benefits to using it, such as improved application performance and enhanced responsiveness.
830844

831845
<div align="right">
832846
<b><a href="#">↥ back to top</a></b>

0 commit comments

Comments
 (0)