-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes
55 lines (42 loc) · 1.51 KB
/
notes
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//1
runtime environment to run JS outside browser in the backend
is a library with built-in modules
runs on google's v8 engine so ultra fast
allows for frontend+backend development in JS
//2
function without name called anonymous function eg- function(){}
callback function concept
//3
global objects- __filename absolute path to file being executed
__dirname absolute path to directory of file being executed
global functions- setTimeout(function, timeinms).. function executed after timeinms seconds
setInterval(function, timeinms).. function executed after every timeinms seconds
//4
asynchronous feature ie callbacks concept
//5
modules contain related code
//6
core modules ie built in modules
http module.. used to create server
//7
one reason nodejs is fast is because it's coded around events
events and event handlers
//8
fs(filesystem) module
every function in fs module has synchronous and asynchronous form
synchronous form blocks execution
asynchronous form doesn't, instead when data is ready calls callback function
//9
streams are UNIX pipes that reads data from a source and pipes that data to a destination
two types- readable and writeable streams
streams used because reading,writing data happen in chunks
//10
piping concept
data 'piped' from source to destination
//11 simple node app
12 creating server
13 organise app code.. ie create and use modules in the main code file
14 routers
15 handling requests
16 responding to requests
17 posting data