File tree Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -904,25 +904,25 @@ Callback is called when task get completed and is asynchronous equivalent for a
904
904
/**
905
905
* Callback Function
906
906
*/
907
- function myAsync (a , b , callback ) {
908
- setTimeout (function () {
909
- callback (a + b);
910
- }, 0 );
907
+ function message (name , callback ) {
908
+ console .log (" Hi" + " " + name);
909
+ callback ();
911
910
}
912
- console .log (" Before Asynchronous Call" );
913
911
914
- myAsync (10 , 20 , function (result ) {
915
- console .log (" Sum: " + result);
916
- });
917
- console .log (" After Asynchronous Call" );
912
+ // Callback function
913
+ function callMe () {
914
+ console .log (" I am callback function" );
915
+ }
916
+
917
+ // Passing function as an argument
918
+ message (" Node.JS" , callMe);
918
919
```
919
920
920
921
** Output:**
921
922
922
923
``` js
923
- Before Asynchronous Call
924
- After Asynchronous Call
925
- Sum: 30
924
+ Hi Node .JS
925
+ I am callback function
926
926
```
927
927
928
928
<div align="right">
You can’t perform that action at this time.
0 commit comments