-
Notifications
You must be signed in to change notification settings - Fork 1
/
tutorial3.js
28 lines (17 loc) · 1.25 KB
/
tutorial3.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Synchronous or Blocking : Line By Line Exceution
// Asynchronous or Non-Blocking : Line By Line Exceution not guranteed. CallBacks will fire.
// We studied ReadFileAsync : What does it mean by Sync??
// Ans : It means That until the file will not be read completely the program will not move towards next line.
// const fs = require("fs");
// var text = fs.readFile("yash.txt", "utf-8", (err,data)=> {
// console.log(err,data)
// });
// console.log("Yash mathur")
// Moral Of the Code : When ReadFile function is called then it starts to read the file and does not stop
// the execution of lines after that. It just says that when i will be done with reading the file then i
// will automatically launch the callback and that would execute what i wanted to.
// So Because of Asynchronous calling the later statements are not stopped from execution.
// It's not like that first 2nd line will be executed and then 1st or other or in any random fashion.
// Actually the execution starts from the 1st line only but whenever a Asynchronous calling is there then
// it just says until i am doing my work you go and complete the remaining work and when this work will
// be completed then i will launch my callback which will ultimately complete this work also.