-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.js
More file actions
72 lines (63 loc) · 1.44 KB
/
functions.js
File metadata and controls
72 lines (63 loc) · 1.44 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
** function
*/
function firstFunction(params) {
console.log("hello " + params);
}
firstFunction("hello")
/**
** Arrow functions
*/
// single line
() => console.log("single");
// multiline
() => {
console.log("multiline");
}
// named arrow function
const name = (params) => {
console.log(params,"named");
}
/**
** Immediately Invoked Function Expressions (IFFY)
* http://adripofjavascript.com/blog/drips/an-introduction-to-iffes-immediately-invoked-function-expressions.html
*/
(function () {
var foo = "bar";
// Outputs: "bar"
console.log(foo);
})();
// ReferenceError: foo is not defined
console.log(foo);
/**
** Event Loop
* 1. Arrays & Memory Heap
* 2. Stack
* 3. Queue
* 4. Call Stack & Callback Queue
* https://blog.sessionstack.com/how-javascript-works-event-loop-and-the-rise-of-async-programming-5-ways-to-better-coding-with-2f077c4438b5
*
*/
/**
** Asynchronous Code
https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous
* 1. Callbacks
* 2. Promises
* 3. Async/Await
* 4. Async Generators
*/
/**
** callbacks
https://www.dashingd3js.com/lessons/javascript-callback-functions
*/
function callback(x) {
console.log(x);
}
function callbackFunction(var1, var2, callback1, callback2) {
callback1(var1);
callback2(var2);
}
callbackFunction( 1, 2, // var1, var2
function (x) { console.log(x); }, // callback1
function (x) { console.log(x); } // callback2
);