-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblogpost.txt
54 lines (31 loc) · 1.61 KB
/
blogpost.txt
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
If you live in the JavaScript world long enough, eventually you or someone you love will be effected by callback hell.
Before explaining how to avoid callback hell, it's probably good to talk to some of the powers of javascript and why
callback hell exists.
Part1: Behold the power of Javascript (a background)
-----------------------------------------------------
Javascript has a few important features that allow for the creation of higher order functions:
The first is that functions are treated as first class objects.
This means that functions can be treated the same as any other object in javascript in that they can be
assigned to variables, passed to functions as arguments, etc.)
The second is that Javascript allows for the creation of anonymous (or unnamed) functions, which means that you can do the following:
named function:
function foo {}
unnamed (anonymous) function:
function() {}
Having first-class functions allows for higher order function
Javascript applications are single threaded.
Follow me on twitter to hear more of my random thoughts on coding, technology, and occasionally rap music.
================================
Synchronous vs Asynchronous Programing
When javascript code block is running, there is no other code is being ran.
Events are asynchronous. (click events, network responses, etc)
Named Methods
Promises
hash = { one: 1, two: 2, three: 3}
for var number in [1, 2, 3] {
for item in hash {
if item = number {
push result, item
}
}
}