WEBVTT

1
00:00:03.355 --> 00:00:03.555
Excellent.

2
00:00:04.575 --> 00:00:06.955
<00:00:04.575>So <00:00:04.730>today <00:00:04.886>we're <00:00:05.041>gonna <00:00:05.197>talk <00:00:05.352>about <00:00:05.508>some <00:00:05.663>of <00:00:05.819>the <00:00:05.975>features

3
00:00:06.955 --> 00:00:09.075
<00:00:06.955>of <00:00:07.188>JavaScript <00:00:07.421>and <00:00:07.655>we'll <00:00:07.888>look <00:00:08.121>at <00:00:08.355>kind

4
00:00:09.075 --> 00:00:10.755
<00:00:09.075>of <00:00:09.354>the <00:00:09.635>dusty <00:00:09.915>edges <00:00:10.194>of <00:00:10.475>JavaScript.

5
00:00:11.045 --> 00:00:14.115
<00:00:11.045>We're <00:00:11.200>gonna <00:00:11.356>learn <00:00:11.511>a <00:00:11.667>lot <00:00:11.822>about <00:00:11.978>how <00:00:12.133>to <00:00:12.289>dig <00:00:12.445>in

6
00:00:14.135 --> 00:00:15.595
<00:00:14.135>and <00:00:14.397>why <00:00:14.660>it <00:00:14.923>works <00:00:15.186>that <00:00:15.449>way.

7
00:00:15.815 --> 00:00:18.115
<00:00:15.815>Here's <00:00:15.942>the <00:00:16.069>part <00:00:16.196>where <00:00:16.324>I <00:00:16.451>tell <00:00:16.578>you <00:00:16.705>I <00:00:16.833>am <00:00:16.960>definitely <00:00:17.087>gonna <00:00:17.215>post

8
00:00:18.115 --> 00:00:19.235
<00:00:18.115>the <00:00:18.316>slides <00:00:18.518>on <00:00:18.719>my <00:00:18.921>site <00:00:19.122>tonight.

9
00:00:20.025 --> 00:00:21.755
<00:00:20.025>I've <00:00:20.258>been <00:00:20.491>that <00:00:20.724>person <00:00:20.958>chasing <00:00:21.191>the <00:00:21.424>speaker

10
00:00:21.775 --> 00:00:23.515
<00:00:21.775>and <00:00:21.974>it <00:00:22.174>hasn't <00:00:22.375>worked <00:00:22.575>out <00:00:22.775>for <00:00:22.974>me <00:00:23.174>either,

11
00:00:23.805 --> 00:00:26.635
<00:00:23.805>which <00:00:23.980>is <00:00:24.155>why <00:00:24.330>you <00:00:24.505>can <00:00:24.680>go <00:00:24.855>to <00:00:25.030>rob <00:00:25.205>rich.org.

12
00:00:26.725 --> 00:00:27.835
<00:00:26.725>Let's <00:00:26.974>head <00:00:27.224>there <00:00:27.474>right <00:00:27.724>now.

13
00:00:28.265 --> 00:00:29.995
<00:00:28.265>I'll <00:00:28.465>click <00:00:28.665>on <00:00:28.865>presentations <00:00:29.065>here <00:00:29.265>at <00:00:29.465>the <00:00:29.665>top,

14
00:00:30.015 --> 00:00:31.795
<00:00:30.015>and <00:00:30.295>here's <00:00:30.575>JavaScript, <00:00:30.855>the <00:00:31.135>Grumpy <00:00:31.415>Parts.

15
00:00:32.175 --> 00:00:34.155
<00:00:32.174>The <00:00:32.455>slides <00:00:32.735>are <00:00:33.015>online <00:00:33.294>right <00:00:33.574>now.

16
00:00:35.245 --> 00:00:37.675
<00:00:35.245>While <00:00:35.525>you're <00:00:35.805>here@robrich.org, <00:00:36.084>let's <00:00:36.364>switch <00:00:36.644>over

17
00:00:37.675 --> 00:00:38.795
<00:00:37.675>to <00:00:37.927>the <00:00:38.179>About <00:00:38.431>Me <00:00:38.683>page

18
00:00:38.795 --> 00:00:39.955
<00:00:38.795>and <00:00:38.944>we'll <00:00:39.093>learn <00:00:39.242>about <00:00:39.391>some <00:00:39.540>of <00:00:39.689>the <00:00:39.839>things

19
00:00:39.955 --> 00:00:41.155
<00:00:39.955>that <00:00:40.315>I've <00:00:40.675>done <00:00:41.035>recently.

20
00:00:41.735 --> 00:00:45.515
<00:00:41.735>I'm <00:00:41.875>a <00:00:42.015>Microsoft <00:00:42.155>MVPA <00:00:42.295>Docker <00:00:42.435>captain <00:00:42.575>and <00:00:42.714>a <00:00:42.855>friend <00:00:42.995>of <00:00:43.135>Redgate.

21
00:00:46.015 --> 00:00:47.635
<00:00:46.015>I'm <00:00:46.365>a <00:00:46.715>S <00:00:47.065>developer <00:00:47.415>advocate.

22
00:00:47.635 --> 00:00:49.195
<00:00:47.635>If <00:00:47.868>you're <00:00:48.101>struggling <00:00:48.335>with <00:00:48.568>your <00:00:48.801>data <00:00:49.035>mesh,

23
00:00:49.275 --> 00:00:50.315
<00:00:49.275>I <00:00:49.431>would <00:00:49.586>love <00:00:49.742>to <00:00:49.899>learn <00:00:50.055>from <00:00:50.211>you.

24
00:00:51.235 --> 00:00:52.555
<00:00:51.235>A <00:00:51.472>Z <00:00:51.710>GCaMP <00:00:51.947>is <00:00:52.185>really <00:00:52.423>fun.

25
00:00:52.755 --> 00:00:55.115
<00:00:52.755>A <00:00:52.988>Z <00:00:53.221>GCaMP <00:00:53.455>brings <00:00:53.688>volunteer <00:00:53.921>developers <00:00:54.155>together

26
00:00:55.115 --> 00:00:57.035
<00:00:55.115>with <00:00:55.395>charities <00:00:55.675>to <00:00:55.955>build <00:00:56.235>free <00:00:56.515>software.

27
00:00:57.455 --> 00:00:58.835
<00:00:57.455>We <00:00:57.765>start <00:00:58.076>building <00:00:58.386>software <00:00:58.697>Friday

28
00:00:58.835 --> 00:01:00.595
<00:00:58.835>after <00:00:59.301>work <00:00:59.768>Sunday <00:01:00.235>afternoon.

29
00:01:00.735 --> 00:01:02.915
<00:01:00.735>We <00:01:00.935>deliver <00:01:01.135>the <00:01:01.335>completed <00:01:01.535>software <00:01:01.735>to <00:01:01.935>the <00:01:02.135>charities.

30
00:01:03.125 --> 00:01:04.875
<00:01:03.125>Sleep <00:01:03.475>is <00:01:03.825>optional. <00:01:04.175>Caffeine <00:01:04.525>provided.

31
00:01:05.335 --> 00:01:07.075
<00:01:05.334>If <00:01:05.568>you're <00:01:05.801>in <00:01:06.035>Phoenix, <00:01:06.268>come <00:01:06.501>join <00:01:06.735>us

32
00:01:07.075 --> 00:01:08.435
<00:01:07.075>for <00:01:07.319>the <00:01:07.564>next <00:01:07.809>AZ <00:01:08.054>gift <00:01:08.299>camp.

33
00:01:08.615 --> 00:01:11.355
<00:01:08.615>Or <00:01:08.755>if <00:01:08.895>you'd <00:01:09.035>like <00:01:09.175>a <00:01:09.315>gift <00:01:09.455>camp <00:01:09.595>where <00:01:09.735>you're <00:01:09.875>connecting <00:01:10.015>from,

34
00:01:11.535 --> 00:01:12.995
<00:01:11.535>hit <00:01:11.753>me <00:01:11.973>up <00:01:12.192>on <00:01:12.411>email <00:01:12.630>or <00:01:12.849>Twitter

35
00:01:13.295 --> 00:01:15.435
<00:01:13.295>and <00:01:13.450>let's <00:01:13.606>get <00:01:13.761>a <00:01:13.917>gift <00:01:14.072>camp <00:01:14.228>in <00:01:14.383>your <00:01:14.539>neighborhood <00:01:14.695>too.

36
00:01:16.105 --> 00:01:17.835
<00:01:16.105>Some <00:01:16.260>of <00:01:16.416>the <00:01:16.571>other <00:01:16.727>things <00:01:16.882>that <00:01:17.038>I've <00:01:17.193>done, <00:01:17.349>I <00:01:17.505>worked

37
00:01:17.895 --> 00:01:19.795
<00:01:17.895>as <00:01:18.128>a <00:01:18.361>core <00:01:18.595>contributor <00:01:18.828>on <00:01:19.061>Gulp <00:01:19.295>in

38
00:01:19.795 --> 00:01:20.995
<00:01:19.795>version <00:01:20.065>two <00:01:20.335>and <00:01:20.605>version <00:01:20.875>three.

39
00:01:21.265 --> 00:01:22.275
<00:01:21.265>That <00:01:21.446>was <00:01:21.628>a <00:01:21.810>lot <00:01:21.992>of <00:01:22.174>fun.

40
00:01:22.695 --> 00:01:25.035
<00:01:22.695>And <00:01:22.835>one <00:01:22.975>of <00:01:23.115>the <00:01:23.255>things <00:01:23.395>I'm <00:01:23.535>particularly <00:01:23.675>proud <00:01:23.815>of, <00:01:23.955>I <00:01:24.095>replied

41
00:01:25.035 --> 00:01:26.755
<00:01:25.035>to <00:01:25.268>a <00:01:25.501>Do <00:01:25.735>Net <00:01:25.968>Rocks <00:01:26.201>podcast <00:01:26.435>episode.

42
00:01:26.945 --> 00:01:29.555
<00:01:26.945>They <00:01:27.052>read <00:01:27.160>my <00:01:27.268>comment <00:01:27.375>on <00:01:27.483>the <00:01:27.591>air <00:01:27.698>and <00:01:27.806>they <00:01:27.914>sent <00:01:28.021>me <00:01:28.129>a <00:01:28.237>mug. <00:01:28.345>Woo.

43
00:01:30.455 --> 00:01:32.995
<00:01:30.455>So <00:01:30.595>there's <00:01:30.735>my <00:01:30.875>claim <00:01:31.015>to <00:01:31.155>fame, <00:01:31.295>my <00:01:31.435>coveted <00:01:31.575>net <00:01:31.715>rocks <00:01:31.855>mug.

44
00:01:33.575 --> 00:01:36.055
<00:01:33.575>So <00:01:33.808>let's <00:01:34.041>dig <00:01:34.275>into <00:01:34.508>job <00:01:34.741>script <00:01:34.975>parts.

45
00:01:36.675 --> 00:01:39.535
<00:01:36.675>Now <00:01:36.815>our <00:01:36.955>goal <00:01:37.095>is <00:01:37.235>less <00:01:37.375>to <00:01:37.515>understand <00:01:37.655>the <00:01:37.795>things <00:01:37.935>that <00:01:38.075>happen,

46
00:01:39.915 --> 00:01:42.095
<00:01:39.914>but <00:01:40.148>more <00:01:40.381>to <00:01:40.615>understand <00:01:40.848>why <00:01:41.081>they <00:01:41.315>happen.

47
00:01:43.255 --> 00:01:45.815
<00:01:43.255>I <00:01:43.429>love <00:01:43.604>this <00:01:43.780>talk <00:01:43.955>by <00:01:44.130>John <00:01:44.304>Mills, <00:01:44.479>a <00:01:44.655>guide

48
00:01:45.815 --> 00:01:47.255
<00:01:45.815>to <00:01:46.247>JavaScript <00:01:46.679>Scary <00:01:47.110>Side.

49
00:01:47.675 --> 00:01:49.975
<00:01:47.675>If <00:01:47.815>you <00:01:47.955>have <00:01:48.095>a <00:01:48.235>chance <00:01:48.375>to <00:01:48.515>listen <00:01:48.655>to <00:01:48.795>John <00:01:48.935>Mills <00:01:49.075>talk,

50
00:01:50.135 --> 00:01:51.455
<00:01:50.134>I <00:01:50.431>would <00:01:50.729>highly <00:01:51.026>recommend <00:01:51.323>it.

51
00:01:52.005 --> 00:01:55.335
<00:01:52.005>This <00:01:52.145>talk <00:01:52.285>actually <00:01:52.425>grew <00:01:52.565>out <00:01:52.705>of <00:01:52.845>a <00:01:52.985>conversation <00:01:53.125>that <00:01:53.265>I <00:01:53.405>had

52
00:01:55.575 --> 00:01:57.255
<00:01:55.575>with <00:01:55.808>John <00:01:56.041>after <00:01:56.275>he <00:01:56.508>did <00:01:56.741>that <00:01:56.975>talk,

53
00:01:57.595 --> 00:01:59.655
<00:01:57.595>and <00:01:57.875>so <00:01:58.155>thanks <00:01:58.435>to <00:01:58.715>Jonathan <00:01:58.995>Mills

54
00:01:59.715 --> 00:02:01.535
<00:01:59.715>for <00:02:00.065>the <00:02:00.415>thoughts <00:02:00.765>around <00:02:01.115>JavaScript.

55
00:02:02.895 --> 00:02:04.475
<00:02:02.895>I'm <00:02:03.175>confident <00:02:03.455>that <00:02:03.735>we're <00:02:04.015>gonna <00:02:04.295>get

56
00:02:04.495 --> 00:02:05.755
<00:02:04.495>to <00:02:04.721>the <00:02:04.948>edge <00:02:05.175>of <00:02:05.402>my <00:02:05.628>knowledge.

57
00:02:05.975 --> 00:02:07.235
<00:02:05.975>I'm <00:02:06.258>actually <00:02:06.542>excited <00:02:06.825>about <00:02:07.109>that.

58
00:02:07.695 --> 00:02:11.435
<00:02:07.695>Uh, <00:02:07.835>the <00:02:07.975>answer <00:02:08.114>to <00:02:08.255>the <00:02:08.394>question <00:02:08.535>may <00:02:08.674>be, <00:02:08.815>I <00:02:08.954>don't <00:02:09.095>know.

59
00:02:12.245 --> 00:02:13.995
<00:02:12.245>Let's <00:02:12.445>see <00:02:12.645>if <00:02:12.845>we <00:02:13.045>can <00:02:13.245>find <00:02:13.445>that <00:02:13.645>edge

60
00:02:14.255 --> 00:02:15.835
<00:02:14.255>and <00:02:14.454>see <00:02:14.655>if <00:02:14.855>I <00:02:15.055>can <00:02:15.255>learn <00:02:15.454>some <00:02:15.655>too.

61
00:02:16.125 --> 00:02:17.635
<00:02:16.125>It'll <00:02:16.319>be <00:02:16.513>fun <00:02:16.707>to <00:02:16.901>learn <00:02:17.095>with <00:02:17.289>you <00:02:17.483>today.

62
00:02:20.095 --> 00:02:22.995
<00:02:20.095>In <00:02:20.561>the <00:02:21.028>beginning, <00:02:21.495>beginning,

63
00:02:23.455 --> 00:02:26.955
<00:02:23.454>Brenda <00:02:23.804>Ike <00:02:24.154>built <00:02:24.505>JavaScript <00:02:24.855>as

64
00:02:27.555 --> 00:02:31.295
<00:02:27.555>a <00:02:27.755>project <00:02:27.955>in <00:02:28.155>10 <00:02:28.355>days, <00:02:28.555>25 <00:02:28.755>years <00:02:28.955>ago.

65
00:02:31.635 --> 00:02:33.415
<00:02:31.635>Now, <00:02:31.810>I <00:02:31.984>don't <00:02:32.160>know <00:02:32.334>about <00:02:32.510>you, <00:02:32.685>but <00:02:32.859>the <00:02:33.035>code

66
00:02:33.415 --> 00:02:35.855
<00:02:33.415>that <00:02:33.590>I <00:02:33.765>wrote <00:02:33.940>25 <00:02:34.114>years <00:02:34.290>ago <00:02:34.465>is <00:02:34.640>pretty <00:02:34.815>awful.

67
00:02:36.615 --> 00:02:40.255
<00:02:36.615>Nobody's <00:02:36.770>talking <00:02:36.926>about <00:02:37.081>it <00:02:37.237>anymore. <00:02:37.392>And <00:02:37.548>yet <00:02:37.703>here <00:02:37.859>we <00:02:38.015>are.

68
00:02:40.425 --> 00:02:43.895
<00:02:40.425>We're <00:02:40.625>all <00:02:40.825>talking <00:02:41.025>about <00:02:41.225>Brendan's <00:02:41.425>10 <00:02:41.625>day <00:02:41.825>project

69
00:02:44.485 --> 00:02:45.895
<00:02:44.485>from <00:02:44.908>25 <00:02:45.331>years <00:02:45.754>ago.

70
00:02:46.435 --> 00:02:47.895
<00:02:46.435>He <00:02:46.763>did <00:02:47.092>an <00:02:47.420>amazing <00:02:47.749>job.

71
00:02:48.315 --> 00:02:50.255
<00:02:48.315>As <00:02:48.548>you <00:02:48.781>grab <00:02:49.015>these <00:02:49.248>slides <00:02:49.481>from <00:02:49.715>roberts.org,

72
00:02:50.395 --> 00:02:53.655
<00:02:50.395>you <00:02:50.511>can <00:02:50.628>click <00:02:50.745>on <00:02:50.861>these <00:02:50.978>blue <00:02:51.095>links <00:02:51.211>to <00:02:51.328>be <00:02:51.445>able <00:02:51.561>to <00:02:51.678>read <00:02:51.795>more

73
00:02:53.715 --> 00:02:57.215
<00:02:53.715>or <00:02:53.915>watch <00:02:54.115>more <00:02:54.315>about <00:02:54.515>how <00:02:54.715>Brendan <00:02:54.915>built <00:02:55.115>JavaScript.

74
00:02:58.075 --> 00:03:01.045
<00:02:58.075>Now <00:02:58.230>he <00:02:58.386>built <00:02:58.541>it <00:02:58.697>in <00:02:58.852>10 <00:02:59.008>days, <00:02:59.163>25 <00:02:59.319>years <00:02:59.475>ago.

75
00:03:01.505 --> 00:03:03.365
<00:03:01.505>But <00:03:01.704>now <00:03:01.905>we <00:03:02.105>have <00:03:02.305>lots <00:03:02.505>of <00:03:02.704>different <00:03:02.905>places

76
00:03:03.415 --> 00:03:07.565
<00:03:03.415>where <00:03:03.554>we <00:03:03.695>can <00:03:03.834>run <00:03:03.975>JavaScript <00:03:04.114>in <00:03:04.255>Chrome <00:03:04.394>and <00:03:04.535>in <00:03:04.674>Node <00:03:04.815>also.

77
00:03:07.565 --> 00:03:11.325
<00:03:07.565>Now <00:03:07.704>in <00:03:07.845>the <00:03:07.984>new <00:03:08.125>Edge <00:03:08.265>we <00:03:08.405>have <00:03:08.545>V <00:03:08.685>eight <00:03:08.825>in <00:03:08.965>Firefox,

78
00:03:11.345 --> 00:03:14.525
<00:03:11.345>we <00:03:11.545>have <00:03:11.745>Spider <00:03:11.945>Monkey, <00:03:12.145>internet <00:03:12.345>Explorer <00:03:12.545>had <00:03:12.745>Chakra

79
00:03:15.165 --> 00:03:16.645
<00:03:15.165>Safari <00:03:15.609>has <00:03:16.053>JavaScript <00:03:16.497>core.

80
00:03:17.255 --> 00:03:21.445
<00:03:17.255>These <00:03:17.410>runtimes <00:03:17.566>all <00:03:17.721>pretty <00:03:17.877>much <00:03:18.032>work <00:03:18.188>the <00:03:18.343>same <00:03:18.499>from <00:03:18.655>a

81
00:03:21.445 --> 00:03:22.885
<00:03:21.445>JavaScript <00:03:22.093>script <00:03:22.741>perspective.

82
00:03:23.145 --> 00:03:25.605
<00:03:23.145>Now, <00:03:23.300>maybe <00:03:23.456>some <00:03:23.611>of <00:03:23.767>them <00:03:23.922>don't <00:03:24.078>have <00:03:24.233>the <00:03:24.389>latest <00:03:24.545>features,

83
00:03:26.065 --> 00:03:28.045
<00:03:26.065>but <00:03:26.531>JavaScript <00:03:26.998>was <00:03:27.465>cloned

84
00:03:28.045 --> 00:03:30.965
<00:03:28.045>with <00:03:28.278>amazing <00:03:28.511>fidelity <00:03:28.745>across <00:03:28.978>all <00:03:29.211>these <00:03:29.445>places.

85
00:03:31.635 --> 00:03:33.755
<00:03:31.635>Well <00:03:32.101>including <00:03:32.568>the <00:03:33.035>bugs.

86
00:03:35.465 --> 00:03:38.635
<00:03:35.465>When <00:03:35.745>when <00:03:36.025>Brendan <00:03:36.305>finished <00:03:36.585>creating <00:03:36.865>JavaScript,

87
00:03:39.015 --> 00:03:41.755
<00:03:39.015>he <00:03:39.154>was <00:03:39.295>noticing <00:03:39.434>some <00:03:39.575>of <00:03:39.714>the <00:03:39.855>early <00:03:39.994>programs <00:03:40.135>that <00:03:40.274>people <00:03:40.415>built

88
00:03:41.755 --> 00:03:44.035
<00:03:41.755>with <00:03:41.930>it <00:03:42.105>and <00:03:42.280>said, <00:03:42.454>you <00:03:42.630>know, <00:03:42.805>there's <00:03:42.980>some <00:03:43.155>bugs

89
00:03:44.035 --> 00:03:45.715
<00:03:44.035>and <00:03:44.190>I <00:03:44.346>kind <00:03:44.501>of <00:03:44.657>wanna <00:03:44.812>go <00:03:44.968>back <00:03:45.123>and <00:03:45.279>fix <00:03:45.435>them.

90
00:03:46.935 --> 00:03:48.235
<00:03:46.935>He <00:03:47.227>was <00:03:47.520>told <00:03:47.812>that, <00:03:48.105>well,

91
00:03:48.365 --> 00:03:50.675
<00:03:48.365>there <00:03:48.598>are <00:03:48.831>40 <00:03:49.065>developers <00:03:49.298>building <00:03:49.531>in <00:03:49.765>JavaScript,

92
00:03:50.695 --> 00:03:51.715
<00:03:50.695>we <00:03:51.001>can't <00:03:51.307>break <00:03:51.613>them.

93
00:03:53.095 --> 00:03:56.195
<00:03:53.095>So <00:03:53.234>he <00:03:53.375>was <00:03:53.515>not <00:03:53.655>allowed <00:03:53.795>to <00:03:53.935>go <00:03:54.075>fix <00:03:54.215>those <00:03:54.355>JavaScript <00:03:54.495>buds.

94
00:03:56.715 --> 00:03:59.715
<00:03:56.715>I <00:03:56.831>bet <00:03:56.948>there's <00:03:57.065>40 <00:03:57.181>people <00:03:57.298>here <00:03:57.415>in <00:03:57.531>the <00:03:57.648>room <00:03:57.765>that <00:03:57.881>wished <00:03:57.998>he <00:03:58.115>had.

95
00:04:00.975 --> 00:04:03.665
<00:04:00.975>Oops. <00:04:01.255>But <00:04:01.535>that <00:04:01.815>gets <00:04:02.095>us <00:04:02.375>nicely

96
00:04:03.845 --> 00:04:05.705
<00:04:03.845>to <00:04:04.195>the <00:04:04.545>methodology <00:04:04.895>of <00:04:05.245>JavaScript.

97
00:04:06.435 --> 00:04:09.945
<00:04:06.435>JavaScript <00:04:06.590>as <00:04:06.746>a <00:04:06.901>language <00:04:07.057>was <00:04:07.212>built <00:04:07.368>to <00:04:07.523>run <00:04:07.679>over <00:04:07.835>there.

98
00:04:11.185 --> 00:04:13.605
<00:04:11.185>Now <00:04:11.465>when <00:04:11.745>we <00:04:12.025>run <00:04:12.305>JavaScript, <00:04:12.585>we

99
00:04:14.205 --> 00:04:15.925
<00:04:14.205>ship <00:04:14.438>our <00:04:14.671>source <00:04:14.905>code <00:04:15.138>to <00:04:15.371>the <00:04:15.605>browser.

100
00:04:16.785 --> 00:04:19.805
<00:04:16.785>In <00:04:16.960>many <00:04:17.135>other <00:04:17.310>cases, <00:04:17.485>we <00:04:17.660>will <00:04:17.835>compile <00:04:18.010>our <00:04:18.185>code

101
00:04:20.105 --> 00:04:21.125
<00:04:20.105>and <00:04:20.411>we'll <00:04:20.716>link <00:04:21.023>it

102
00:04:21.225 --> 00:04:24.135
<00:04:21.225>and <00:04:21.458>we'll <00:04:21.691>ship <00:04:21.925>an <00:04:22.158>executable <00:04:22.391>with <00:04:22.625>JavaScript.

103
00:04:24.135 --> 00:04:27.055
<00:04:24.135>That's <00:04:24.335>not <00:04:24.534>the <00:04:24.735>case. <00:04:24.935>The <00:04:25.135>browser <00:04:25.335>downloads <00:04:25.534>source

104
00:04:27.085 --> 00:04:28.255
<00:04:27.085>code <00:04:27.436>and <00:04:27.787>runs <00:04:28.138>it.

105
00:04:28.875 --> 00:04:31.615
<00:04:28.875>Now <00:04:29.050>that <00:04:29.225>means <00:04:29.400>that <00:04:29.575>we're <00:04:29.750>probably <00:04:29.925>running <00:04:30.100>an <00:04:30.275>environment

106
00:04:31.865 --> 00:04:33.855
<00:04:31.865>where <00:04:32.215>the <00:04:32.565>developer <00:04:32.915>has <00:04:33.265>left.

107
00:04:34.765 --> 00:04:37.345
<00:04:34.765>So <00:04:35.044>the <00:04:35.325>goal <00:04:35.604>of <00:04:35.885>JavaScript <00:04:36.164>is

108
00:04:37.345 --> 00:04:39.345
<00:04:37.345>to <00:04:37.625>keep <00:04:37.905>this <00:04:38.185>running <00:04:38.465>whenever <00:04:38.745>possible.

109
00:04:39.965 --> 00:04:42.745
<00:04:39.965>If <00:04:40.165>JavaScript <00:04:40.365>encounters <00:04:40.565>the <00:04:40.765>syntax <00:04:40.965>error, <00:04:41.165>it'll <00:04:41.365>try

110
00:04:42.745 --> 00:04:44.865
<00:04:42.745>and <00:04:42.900>back <00:04:43.056>up <00:04:43.211>and <00:04:43.367>see <00:04:43.522>if <00:04:43.678>it <00:04:43.833>can <00:04:43.989>fix <00:04:44.145>it.

111
00:04:45.645 --> 00:04:46.985
<00:04:45.645>Now <00:04:46.046>that's <00:04:46.449>really <00:04:46.851>beneficial.

112
00:04:47.165 --> 00:04:48.545
<00:04:47.165>You <00:04:47.413>know, <00:04:47.661>the <00:04:47.910>developer <00:04:48.158>has <00:04:48.407>left.

113
00:04:48.965 --> 00:04:51.825
<00:04:48.965>We <00:04:49.092>want <00:04:49.219>to <00:04:49.346>keep <00:04:49.474>the <00:04:49.601>web <00:04:49.728>running <00:04:49.855>as <00:04:49.983>much <00:04:50.110>as <00:04:50.237>we <00:04:50.365>can,

114
00:04:52.285 --> 00:04:54.185
<00:04:52.284>but <00:04:52.984>pardon <00:04:53.684>me.

115
00:04:55.085 --> 00:04:57.705
<00:04:55.085>But <00:04:55.284>that <00:04:55.484>does <00:04:55.685>lead <00:04:55.885>to <00:04:56.085>some <00:04:56.284>interesting <00:04:56.484>things.

116
00:04:58.125 --> 00:05:00.185
<00:04:58.125>One <00:04:58.300>of <00:04:58.475>the <00:04:58.650>questions <00:04:58.825>that <00:04:59.000>we <00:04:59.175>often <00:04:59.350>ask <00:04:59.525>is,

117
00:05:00.565 --> 00:05:02.505
<00:05:00.565>are <00:05:00.915>semicolons <00:05:01.265>required <00:05:01.615>in <00:05:01.965>JavaScript?

118
00:05:03.255 --> 00:05:06.025
<00:05:03.255>Well, <00:05:03.534>yes, <00:05:03.815>they <00:05:04.094>are <00:05:04.375>JavaScript's <00:05:04.655>runtime.

119
00:05:06.025 --> 00:05:07.745
<00:05:06.025>It's <00:05:06.258>just <00:05:06.491>really <00:05:06.724>good <00:05:06.958>at <00:05:07.191>inserting <00:05:07.424>them

120
00:05:07.765 --> 00:05:08.785
<00:05:07.765>if <00:05:07.994>we <00:05:08.224>leave <00:05:08.453>them <00:05:08.683>out.

121
00:05:09.645 --> 00:05:13.105
<00:05:09.645>So <00:05:09.800>if <00:05:09.956>you <00:05:10.111>do <00:05:10.267>code <00:05:10.422>in <00:05:10.578>JavaScript <00:05:10.733>without <00:05:10.889>semicolons, <00:05:11.044>know

122
00:05:13.105 --> 00:05:14.305
<00:05:13.105>that <00:05:13.375>when <00:05:13.645>your <00:05:13.915>code <00:05:14.185>runs,

123
00:05:14.715 --> 00:05:16.545
<00:05:14.715>those <00:05:15.065>semicolons <00:05:15.414>will <00:05:15.765>get <00:05:16.114>inserted.

124
00:05:16.885 --> 00:05:19.065
<00:05:16.885>Now <00:05:17.085>maybe <00:05:17.284>you <00:05:17.485>have <00:05:17.685>babble <00:05:17.885>or <00:05:18.085>web <00:05:18.284>pack

125
00:05:19.165 --> 00:05:23.105
<00:05:19.165>or <00:05:19.365>another <00:05:19.565>ER <00:05:19.765>that <00:05:19.965>will <00:05:20.165>modify <00:05:20.365>your <00:05:20.565>code

126
00:05:23.125 --> 00:05:24.185
<00:05:23.125>and <00:05:23.443>do <00:05:23.761>interesting <00:05:24.079>things

127
00:05:24.405 --> 00:05:26.065
<00:05:24.405>so <00:05:24.604>you're <00:05:24.804>not <00:05:25.005>actually <00:05:25.205>shipping <00:05:25.405>the <00:05:25.604>source <00:05:25.804>code

128
00:05:26.065 --> 00:05:29.225
<00:05:26.065>that <00:05:26.240>you <00:05:26.415>wrote, <00:05:26.590>but <00:05:26.765>you <00:05:26.940>are <00:05:27.115>still <00:05:27.290>shipping <00:05:27.465>JavaScript

129
00:05:29.225 --> 00:05:30.385
<00:05:29.225>source <00:05:29.486>code <00:05:29.747>to <00:05:30.008>the <00:05:30.269>browser.

130
00:05:31.045 --> 00:05:33.705
<00:05:31.045>The <00:05:31.220>code <00:05:31.395>will <00:05:31.570>run <00:05:31.745>over <00:05:31.920>there <00:05:32.095>in <00:05:32.270>this <00:05:32.445>memory

131
00:05:33.705 --> 00:05:34.745
<00:05:33.705>constrained <00:05:34.641>space.

132
00:05:36.855 --> 00:05:39.675
<00:05:36.855>So <00:05:37.088>JavaScript <00:05:37.321>has <00:05:37.555>some <00:05:37.788>really <00:05:38.021>weird <00:05:38.255>parts.

133
00:05:41.735 --> 00:05:44.385
<00:05:41.735>This <00:05:41.890>talk <00:05:42.046>as <00:05:42.201>you <00:05:42.357>grab <00:05:42.512>the <00:05:42.668>slides <00:05:42.823>from <00:05:42.979>rob <00:05:43.135>rich.org,

134
00:05:44.505 --> 00:05:47.025
<00:05:44.505>I <00:05:44.645>invite <00:05:44.784>you <00:05:44.925>to <00:05:45.065>push <00:05:45.205>play <00:05:45.344>here <00:05:45.485>and <00:05:45.625>watch <00:05:45.765>this <00:05:45.905>video.

135
00:05:47.635 --> 00:05:49.945
<00:05:47.635>JavaScript <00:05:47.914>wat <00:05:48.195>is <00:05:48.474>an <00:05:48.755>amazing <00:05:49.034>talk

136
00:05:50.045 --> 00:05:53.905
<00:05:50.045>and <00:05:50.200>this <00:05:50.356>is <00:05:50.511>actually <00:05:50.667>Brendan <00:05:50.822>Ike <00:05:50.978>playing <00:05:51.133>it <00:05:51.289>at <00:05:51.445>one

137
00:05:53.905 --> 00:05:55.425
<00:05:53.905>of <00:05:54.178>his <00:05:54.452>talks <00:05:54.725>at <00:05:54.999>Fluent <00:05:55.273>Conf.

138
00:05:55.645 --> 00:05:56.705
<00:05:55.645>It <00:05:55.962>is <00:05:56.281>really <00:05:56.599>cool.

139
00:05:57.145 --> 00:05:59.645
<00:05:57.145>He <00:05:57.284>stops <00:05:57.424>the <00:05:57.565>video <00:05:57.705>from <00:05:57.844>time <00:05:57.984>to <00:05:58.125>time <00:05:58.265>and <00:05:58.405>adds <00:05:58.544>commentary.

140
00:06:00.355 --> 00:06:03.545
<00:06:00.355>It's <00:06:00.555>amazing. <00:06:00.755>Now <00:06:00.955>we're <00:06:01.155>not <00:06:01.355>gonna <00:06:01.555>go <00:06:01.755>into

141
00:06:03.845 --> 00:06:04.945
<00:06:03.845>all <00:06:04.092>of <00:06:04.340>the <00:06:04.587>wat <00:06:04.835>things.

142
00:06:05.395 --> 00:06:06.865
<00:06:05.395>Let's <00:06:05.584>talk <00:06:05.772>about <00:06:05.962>a <00:06:06.151>few <00:06:06.340>of <00:06:06.529>the <00:06:06.718>things

143
00:06:06.865 --> 00:06:09.145
<00:06:06.865>that <00:06:07.065>are <00:06:07.265>a <00:06:07.465>little <00:06:07.665>bit <00:06:07.865>weird <00:06:08.065>about <00:06:08.265>JavaScript.

144
00:06:10.235 --> 00:06:12.045
<00:06:10.235>Undefined <00:06:10.935>equals <00:06:11.635>defined.

145
00:06:12.545 --> 00:06:14.765
<00:06:12.545>Now, <00:06:12.778>undefined <00:06:13.011>is <00:06:13.245>a <00:06:13.478>variable <00:06:13.711>in <00:06:13.945>JavaScript

146
00:06:14.765 --> 00:06:15.885
<00:06:14.765>just <00:06:15.101>like <00:06:15.437>anything <00:06:15.772>else.

147
00:06:16.025 --> 00:06:18.325
<00:06:16.025>And <00:06:16.258>so <00:06:16.491>we <00:06:16.724>could <00:06:16.958>set <00:06:17.191>its <00:06:17.424>value

148
00:06:19.145 --> 00:06:20.965
<00:06:19.145>in <00:06:19.424>more <00:06:19.705>modern <00:06:19.984>versions <00:06:20.265>of <00:06:20.544>JavaScript.

149
00:06:20.965 --> 00:06:23.165
<00:06:20.965>Undefined <00:06:21.164>is <00:06:21.364>a <00:06:21.565>constant, <00:06:21.765>so <00:06:21.965>this <00:06:22.164>will <00:06:22.364>error.

150
00:06:23.625 --> 00:06:27.325
<00:06:23.625>But <00:06:23.825>uh, <00:06:24.025>yeah, <00:06:24.225>we <00:06:24.425>could <00:06:24.625>set <00:06:24.825>undefined, <00:06:25.025>which

151
00:06:28.115 --> 00:06:30.805
<00:06:28.115>changes <00:06:28.290>a <00:06:28.465>lot <00:06:28.640>of <00:06:28.815>things <00:06:28.990>in <00:06:29.165>really <00:06:29.340>interesting <00:06:29.515>ways,

152
00:06:31.835 --> 00:06:32.845
<00:06:31.835>type <00:06:32.289>of <00:06:32.744>null.

153
00:06:33.915 --> 00:06:38.295
<00:06:33.915>Now <00:06:34.042>this <00:06:34.169>is <00:06:34.296>weird. <00:06:34.424>Why <00:06:34.551>is <00:06:34.678>the <00:06:34.805>type <00:06:34.933>of <00:06:35.060>null <00:06:35.187>an <00:06:35.315>object?

154
00:06:39.345 --> 00:06:41.695
<00:06:39.345>Maybe <00:06:39.500>this <00:06:39.656>is <00:06:39.811>one <00:06:39.967>of <00:06:40.122>the <00:06:40.278>bugs <00:06:40.433>that <00:06:40.589>Brendan <00:06:40.745>wanted

155
00:06:41.695 --> 00:06:43.575
<00:06:41.695>to <00:06:41.974>fix <00:06:42.255>all <00:06:42.534>those <00:06:42.815>years <00:06:43.094>ago.

156
00:06:43.985 --> 00:06:48.015
<00:06:43.985>Maybe <00:06:44.140>type <00:06:44.296>of <00:06:44.451>null <00:06:44.607>should <00:06:44.762>be <00:06:44.918>undefined <00:06:45.073>instead <00:06:45.229>of <00:06:45.385>object.

157
00:06:49.245 --> 00:06:52.955
<00:06:49.245>That's <00:06:49.478>interesting. <00:06:49.711>Next <00:06:49.945>up, <00:06:50.178>type <00:06:50.411>of <00:06:50.645>nan

158
00:06:53.785 --> 00:06:54.955
<00:06:53.784>type <00:06:54.048>of <00:06:54.311>not <00:06:54.574>a <00:06:54.837>number.

159
00:06:55.335 --> 00:06:57.795
<00:06:55.335>Now <00:06:55.474>why <00:06:55.614>would <00:06:55.755>type <00:06:55.895>of <00:06:56.034>not <00:06:56.174>a <00:06:56.315>number <00:06:56.455>be <00:06:56.594>a <00:06:56.734>number?

160
00:06:59.065 --> 00:07:03.235
<00:06:59.065>Well, <00:06:59.240>as <00:06:59.415>we <00:06:59.590>look <00:06:59.765>at <00:06:59.940>JavaScript's <00:07:00.115>types, <00:07:00.290>there's <00:07:00.465>number

161
00:07:03.865 --> 00:07:06.875
<00:07:03.865>Boolean <00:07:04.331>string <00:07:04.798>function <00:07:05.265>object.

162
00:07:07.815 --> 00:07:11.095
<00:07:07.815>I <00:07:07.922>guess <00:07:08.030>it <00:07:08.138>kind <00:07:08.245>of <00:07:08.353>fits <00:07:08.461>in <00:07:08.568>the <00:07:08.676>number <00:07:08.784>group <00:07:08.891>more <00:07:08.999>so <00:07:09.107>than <00:07:09.215>any

163
00:07:11.095 --> 00:07:12.135
<00:07:11.095>of <00:07:11.407>those <00:07:11.719>other <00:07:12.031>groups.

164
00:07:12.715 --> 00:07:17.415
<00:07:12.715>But <00:07:12.831>the <00:07:12.948>fact <00:07:13.065>that <00:07:13.181>not <00:07:13.298>a <00:07:13.414>number <00:07:13.531>is <00:07:13.648>of <00:07:13.765>type <00:07:13.881>number, <00:07:13.998>uh, <00:07:14.114>yeah,

165
00:07:17.415 --> 00:07:18.495
<00:07:17.415>that <00:07:17.658>feels <00:07:17.901>a <00:07:18.144>little <00:07:18.387>weird.

166
00:07:20.355 --> 00:07:22.975
<00:07:20.355>Now <00:07:20.555>as <00:07:20.755>we <00:07:20.955>dig <00:07:21.155>into <00:07:21.355>JavaScript, <00:07:21.555>let's <00:07:21.755>start

167
00:07:23.035 --> 00:07:25.935
<00:07:23.035>to <00:07:23.190>see <00:07:23.346>if <00:07:23.501>we <00:07:23.657>can <00:07:23.812>understand <00:07:23.968>why <00:07:24.123>these <00:07:24.279>things <00:07:24.435>happen

168
00:07:26.595 --> 00:07:28.095
<00:07:26.595>and <00:07:26.932>maybe <00:07:27.270>that'll <00:07:27.607>help <00:07:27.945>us

169
00:07:28.155 --> 00:07:30.135
<00:07:28.155>to <00:07:28.505>understand <00:07:28.854>more <00:07:29.205>about <00:07:29.554>JavaScript

170
00:07:30.275 --> 00:07:32.255
<00:07:30.275>and <00:07:30.474>make <00:07:30.674>these <00:07:30.875>things <00:07:31.075>a <00:07:31.275>little <00:07:31.474>less <00:07:31.674>weird.

171
00:07:32.985 --> 00:07:35.335
<00:07:32.985>Let's <00:07:33.265>start <00:07:33.545>by <00:07:33.825>examining <00:07:34.105>the <00:07:34.385>compiler.

172
00:07:36.335 --> 00:07:39.795
<00:07:36.335>Now <00:07:36.510>the <00:07:36.685>JavaScript <00:07:36.859>compiler <00:07:37.034>is <00:07:37.210>a <00:07:37.385>two <00:07:37.560>pass <00:07:37.734>compiler.

173
00:07:40.135 --> 00:07:42.115
<00:07:40.135>As <00:07:40.335>you <00:07:40.534>grab <00:07:40.735>these <00:07:40.935>slides <00:07:41.135>from <00:07:41.335>rob <00:07:41.534>rich.org,

174
00:07:42.245 --> 00:07:44.635
<00:07:42.245>click <00:07:42.400>on <00:07:42.556>these <00:07:42.711>two <00:07:42.867>links <00:07:43.022>to <00:07:43.178>be <00:07:43.333>able <00:07:43.489>to <00:07:43.645>read

175
00:07:44.695 --> 00:07:46.955
<00:07:44.695>or <00:07:44.928>watch <00:07:45.161>more <00:07:45.395>about <00:07:45.628>the <00:07:45.861>JavaScript <00:07:46.094>compiler.

176
00:07:47.535 --> 00:07:50.635
<00:07:47.534>Now <00:07:47.710>the <00:07:47.885>JavaScript <00:07:48.059>compiler <00:07:48.234>is <00:07:48.409>this <00:07:48.585>two <00:07:48.760>pass <00:07:48.934>compiler

177
00:07:50.665 --> 00:07:54.725
<00:07:50.665>that <00:07:50.792>allows <00:07:50.919>us <00:07:51.046>to <00:07:51.174>first <00:07:51.301>take <00:07:51.428>a <00:07:51.555>look <00:07:51.683>at <00:07:51.810>all <00:07:51.937>the <00:07:52.065>code

178
00:07:54.745 --> 00:07:58.725
<00:07:54.745>and <00:07:54.920>identify <00:07:55.095>the <00:07:55.270>allocations <00:07:55.445>and <00:07:55.620>second <00:07:55.795>execute <00:07:55.970>the <00:07:56.145>code.

179
00:08:00.285 --> 00:08:02.145
<00:08:00.285>So <00:08:00.440>let's <00:08:00.596>take <00:08:00.751>a <00:08:00.907>look <00:08:01.062>at <00:08:01.218>a <00:08:01.373>piece <00:08:01.529>of <00:08:01.685>code

180
00:08:02.285 --> 00:08:03.865
<00:08:02.285>and <00:08:02.565>see <00:08:02.845>how <00:08:03.125>this <00:08:03.405>might <00:08:03.685>work.

181
00:08:04.595 --> 00:08:07.225
<00:08:04.595>Let's <00:08:04.750>think <00:08:04.906>like <00:08:05.061>the <00:08:05.217>compiler <00:08:05.372>and <00:08:05.528>figure <00:08:05.683>out <00:08:05.839>this <00:08:05.995>code.

182
00:08:07.965 --> 00:08:10.145
<00:08:07.965>So <00:08:08.120>our <00:08:08.276>first <00:08:08.431>step <00:08:08.587>is <00:08:08.742>to <00:08:08.898>go <00:08:09.053>look <00:08:09.209>for <00:08:09.364>allocations.

183
00:08:10.845 --> 00:08:13.785
<00:08:10.845>Now <00:08:11.045>we've <00:08:11.245>allocated <00:08:11.445>this <00:08:11.645>FU <00:08:11.845>variable <00:08:12.045>right <00:08:12.245>here

184
00:08:14.365 --> 00:08:15.585
<00:08:14.365>and <00:08:14.639>that's <00:08:14.914>the <00:08:15.188>first <00:08:15.462>pass.

185
00:08:16.165 --> 00:08:18.425
<00:08:16.165>Our <00:08:16.365>second <00:08:16.565>pass <00:08:16.765>is <00:08:16.965>to <00:08:17.165>execute <00:08:17.365>the <00:08:17.565>code.

186
00:08:18.805 --> 00:08:21.705
<00:08:18.805>So <00:08:18.980>let's <00:08:19.155>define <00:08:19.330>this <00:08:19.505>function <00:08:19.680>and <00:08:19.855>then <00:08:20.030>execute <00:08:20.205>it.

187
00:08:22.165 --> 00:08:25.105
<00:08:22.165>Now <00:08:22.340>inside <00:08:22.515>this <00:08:22.690>function, <00:08:22.865>we'll <00:08:23.040>go <00:08:23.215>console <00:08:23.390>log <00:08:23.565>fu.

188
00:08:26.005 --> 00:08:28.985
<00:08:26.005>Now <00:08:26.145>remember <00:08:26.284>in <00:08:26.425>the <00:08:26.565>first <00:08:26.705>pass <00:08:26.844>we <00:08:26.985>allocated <00:08:27.125>this <00:08:27.265>FU <00:08:27.405>variable

189
00:08:29.485 --> 00:08:32.265
<00:08:29.485>and <00:08:29.685>variables <00:08:29.885>are <00:08:30.085>defined <00:08:30.285>with <00:08:30.485>function <00:08:30.685>level <00:08:30.885>scope,

190
00:08:32.565 --> 00:08:33.665
<00:08:32.565>not <00:08:32.895>curly <00:08:33.225>brace <00:08:33.554>scope.

191
00:08:34.125 --> 00:08:36.065
<00:08:34.125>So <00:08:34.325>this <00:08:34.525>foo <00:08:34.725>variable <00:08:34.924>is <00:08:35.125>in <00:08:35.325>scope <00:08:35.525>here,

192
00:08:36.205 --> 00:08:37.905
<00:08:36.205>but <00:08:36.555>its <00:08:36.905>value <00:08:37.255>is <00:08:37.605>unset.

193
00:08:38.645 --> 00:08:41.065
<00:08:38.645>So <00:08:38.819>when <00:08:38.995>we <00:08:39.169>console <00:08:39.345>log <00:08:39.520>here, <00:08:39.694>we'll <00:08:39.870>get <00:08:40.044>undefined.

194
00:08:42.005 --> 00:08:44.385
<00:08:42.005>Now <00:08:42.179>inside <00:08:42.355>this <00:08:42.530>true <00:08:42.705>block <00:08:42.880>we <00:08:43.054>will <00:08:43.230>define <00:08:43.405>it.

195
00:08:44.485 --> 00:08:46.625
<00:08:44.485>So <00:08:44.718>what <00:08:44.951>was <00:08:45.185>undefined <00:08:45.418>is <00:08:45.651>now <00:08:45.885>bar

196
00:08:46.845 --> 00:08:49.785
<00:08:46.845>and <00:08:46.985>we <00:08:47.125>will <00:08:47.265>now <00:08:47.405>console <00:08:47.545>log <00:08:47.685>its <00:08:47.825>value, <00:08:47.965>which <00:08:48.105>is <00:08:48.245>bar.

197
00:08:51.265 --> 00:08:53.045
<00:08:51.265>So <00:08:51.615>that's <00:08:51.965>kind <00:08:52.314>of <00:08:52.665>interesting.

198
00:08:53.385 --> 00:08:55.565
<00:08:53.385>In <00:08:53.585>most <00:08:53.785>languages, <00:08:53.985>if <00:08:54.185>we <00:08:54.385>used <00:08:54.585>a <00:08:54.785>variable

199
00:08:55.565 --> 00:08:57.165
<00:08:55.565>before <00:08:55.798>we <00:08:56.031>declared <00:08:56.265>it, <00:08:56.498>it <00:08:56.731>would <00:08:56.965>error.

200
00:08:57.945 --> 00:09:00.525
<00:08:57.945>But <00:08:58.145>because <00:08:58.345>of <00:08:58.545>the <00:08:58.745>JavaScript <00:08:58.945>two <00:08:59.145>pass <00:08:59.345>compiler,

201
00:09:00.755 --> 00:09:02.285
<00:09:00.755>that <00:09:01.030>actually <00:09:01.305>works <00:09:01.581>out <00:09:01.856>just <00:09:02.132>fine.

202
00:09:03.325 --> 00:09:06.465
<00:09:03.325>So <00:09:03.525>we <00:09:03.725>have <00:09:03.925>this <00:09:04.125>mechanism <00:09:04.325>called <00:09:04.525>variable <00:09:04.725>hoisting

203
00:09:07.325 --> 00:09:09.785
<00:09:07.325>and <00:09:07.500>in <00:09:07.675>effect <00:09:07.850>we're <00:09:08.025>gonna <00:09:08.200>take <00:09:08.375>this <00:09:08.550>foo <00:09:08.725>variable

204
00:09:09.925 --> 00:09:12.745
<00:09:09.925>and <00:09:10.099>we're <00:09:10.275>going <00:09:10.449>to <00:09:10.625>move <00:09:10.800>it <00:09:10.974>to <00:09:11.150>define <00:09:11.324>here.

205
00:09:13.965 --> 00:09:15.305
<00:09:13.965>Now <00:09:14.367>that's <00:09:14.769>a <00:09:15.170>lie

206
00:09:16.345 --> 00:09:19.545
<00:09:16.345>variable <00:09:16.485>hoisting <00:09:16.625>is <00:09:16.765>a <00:09:16.905>convenient <00:09:17.045>lie, <00:09:17.185>but <00:09:17.325>it <00:09:17.465>is <00:09:17.605>a <00:09:17.745>lie.

207
00:09:19.615 --> 00:09:22.625
<00:09:19.615>It's <00:09:19.731>a <00:09:19.848>lie <00:09:19.965>that <00:09:20.081>we <00:09:20.198>tell <00:09:20.315>ourselves <00:09:20.431>to <00:09:20.548>be <00:09:20.665>able <00:09:20.781>to <00:09:20.898>not <00:09:21.015>have

208
00:09:22.625 --> 00:09:24.705
<00:09:22.625>to <00:09:22.858>think <00:09:23.091>about <00:09:23.325>that <00:09:23.558>two <00:09:23.791>phase <00:09:24.025>compiler.

209
00:09:26.345 --> 00:09:29.235
<00:09:26.345>Yeah, <00:09:26.695>hoisting <00:09:27.045>it's <00:09:27.395>a <00:09:27.745>lie.

210
00:09:29.235 --> 00:09:30.715
<00:09:29.235>That's <00:09:29.501>not <00:09:29.767>actually <00:09:30.034>how <00:09:30.300>it <00:09:30.567>works,

211
00:09:31.175 --> 00:09:33.755
<00:09:31.175>but <00:09:31.349>it's <00:09:31.525>a <00:09:31.699>convenient <00:09:31.875>lie <00:09:32.050>that <00:09:32.224>helps <00:09:32.400>us <00:09:32.574>kind

212
00:09:33.755 --> 00:09:36.595
<00:09:33.755>of <00:09:33.882>think <00:09:34.009>about <00:09:34.136>it <00:09:34.264>in <00:09:34.391>one <00:09:34.518>pass <00:09:34.645>rather <00:09:34.773>than <00:09:34.900>think <00:09:35.027>about <00:09:35.155>the

213
00:09:36.595 --> 00:09:39.355
<00:09:36.595>JavaScript <00:09:36.945>compiler <00:09:37.295>two <00:09:37.645>pass <00:09:37.995>mechanism.

214
00:09:41.415 --> 00:09:43.915
<00:09:41.415>Now <00:09:41.570>let's <00:09:41.726>take <00:09:41.881>a <00:09:42.037>look <00:09:42.192>at <00:09:42.348>lots <00:09:42.503>of <00:09:42.659>other <00:09:42.814>mechanisms

215
00:09:44.005 --> 00:09:46.435
<00:09:44.005>where <00:09:44.180>we <00:09:44.355>can <00:09:44.530>kind <00:09:44.705>of <00:09:44.880>think <00:09:45.055>like <00:09:45.230>the <00:09:45.405>compiler.

216
00:09:46.695 --> 00:09:47.995
<00:09:46.695>Now <00:09:46.929>we <00:09:47.163>look <00:09:47.397>through <00:09:47.631>this <00:09:47.865>example,

217
00:09:48.455 --> 00:09:52.235
<00:09:48.455>but <00:09:48.630>let's <00:09:48.805>look <00:09:48.980>through <00:09:49.155>some <00:09:49.330>a <00:09:49.505>bunch <00:09:49.680>more <00:09:49.855>examples

218
00:09:52.295 --> 00:09:56.075
<00:09:52.295>and <00:09:52.422>see <00:09:52.549>if <00:09:52.676>we <00:09:52.804>can <00:09:52.931>figure <00:09:53.058>out <00:09:53.185>how <00:09:53.313>the <00:09:53.440>compiler <00:09:53.567>will <00:09:53.694>define

219
00:09:56.215 --> 00:10:00.315
<00:09:56.215>or <00:09:56.342>not <00:09:56.469>define <00:09:56.596>variables <00:09:56.724>based <00:09:56.851>on <00:09:56.978>the <00:09:57.105>way <00:09:57.233>we <00:09:57.360>create <00:09:57.487>our <00:09:57.615>code.

220
00:10:01.255 --> 00:10:04.595
<00:10:01.255>So <00:10:01.410>in <00:10:01.566>this <00:10:01.721>example <00:10:01.877>I'm <00:10:02.032>gonna <00:10:02.188>declare <00:10:02.343>these <00:10:02.499>two <00:10:02.655>variables.

221
00:10:04.595 --> 00:10:06.515
<00:10:04.595>Maybe <00:10:04.770>we <00:10:04.945>call <00:10:05.120>it <00:10:05.295>FU <00:10:05.470>one <00:10:05.645>and <00:10:05.820>F <00:10:05.995>two

222
00:10:06.775 --> 00:10:08.595
<00:10:06.775>or <00:10:06.975>the <00:10:07.175>outer <00:10:07.375>FU <00:10:07.574>and <00:10:07.775>the <00:10:07.975>inner <00:10:08.175>fu.

223
00:10:09.795 --> 00:10:13.405
<00:10:09.795>Take <00:10:09.935>a <00:10:10.074>moment <00:10:10.214>and <00:10:10.354>figure <00:10:10.495>out <00:10:10.635>what <00:10:10.775>happens <00:10:10.915>in <00:10:11.055>this <00:10:11.194>case.

224
00:10:17.775 --> 00:10:19.355
<00:10:17.775>Now <00:10:18.055>let's <00:10:18.334>think <00:10:18.615>like <00:10:18.895>the <00:10:19.175>compiler

225
00:10:19.355 --> 00:10:20.835
<00:10:19.355>and <00:10:19.545>see <00:10:19.735>if <00:10:19.925>we <00:10:20.116>can <00:10:20.306>figure <00:10:20.496>it <00:10:20.687>out.

226
00:10:21.375 --> 00:10:24.955
<00:10:21.375>Our <00:10:21.550>first <00:10:21.725>pass <00:10:21.900>is <00:10:22.075>to <00:10:22.250>allocate <00:10:22.425>all <00:10:22.600>the <00:10:22.775>variables.

227
00:10:25.025 --> 00:10:27.435
<00:10:25.025>Okay, <00:10:25.165>so <00:10:25.305>we've <00:10:25.444>got <00:10:25.584>our <00:10:25.725>outer <00:10:25.865>FU <00:10:26.005>and <00:10:26.145>our <00:10:26.285>inner <00:10:26.425>fu.

228
00:10:27.435 --> 00:10:29.435
<00:10:27.435>Those <00:10:27.590>are <00:10:27.746>the <00:10:27.901>two <00:10:28.057>variables <00:10:28.212>that <00:10:28.368>we <00:10:28.523>want <00:10:28.679>to <00:10:28.834>declare.

229
00:10:29.815 --> 00:10:32.235
<00:10:29.815>Now <00:10:29.990>our <00:10:30.165>next <00:10:30.340>phase <00:10:30.515>is <00:10:30.690>to <00:10:30.865>execute <00:10:31.040>the <00:10:31.215>code.

230
00:10:33.295 --> 00:10:34.625
<00:10:33.295>Okay, <00:10:33.594>here's <00:10:33.893>our <00:10:34.192>first <00:10:34.492>statement.

231
00:10:34.625 --> 00:10:37.745
<00:10:34.625>We're <00:10:34.765>gonna <00:10:34.905>set <00:10:35.045>FU <00:10:35.185>equal <00:10:35.325>to <00:10:35.465>bar, <00:10:35.605>we'll <00:10:35.745>define <00:10:35.885>a <00:10:36.025>function.

232
00:10:37.955 --> 00:10:39.265
<00:10:37.955>We'll <00:10:38.348>execute <00:10:38.741>that <00:10:39.134>function.

233
00:10:39.565 --> 00:10:41.585
<00:10:39.565>And <00:10:39.845>now <00:10:40.125>inside <00:10:40.405>our <00:10:40.685>bar <00:10:40.965>function

234
00:10:42.635 --> 00:10:45.505
<00:10:42.635>we're <00:10:42.810>gonna <00:10:42.985>set <00:10:43.160>our <00:10:43.335>inner <00:10:43.510>FU <00:10:43.685>variable <00:10:43.860>to <00:10:44.035>bas.

235
00:10:46.695 --> 00:10:49.075
<00:10:46.695>Now <00:10:46.895>variables <00:10:47.095>are <00:10:47.295>scoped <00:10:47.495>with <00:10:47.695>curly <00:10:47.895>brace <00:10:48.095>scope.

236
00:10:49.175 --> 00:10:52.035
<00:10:49.175>So <00:10:49.330>this <00:10:49.486>if <00:10:49.641>true <00:10:49.797>doesn't <00:10:49.952>affect <00:10:50.108>how <00:10:50.263>we <00:10:50.419>find <00:10:50.574>variables

237
00:10:52.095 --> 00:10:54.195
<00:10:52.095>and <00:10:52.295>we <00:10:52.495>go <00:10:52.695>looking <00:10:52.895>for <00:10:53.095>this <00:10:53.295>FU <00:10:53.495>variable.

238
00:10:54.655 --> 00:10:57.235
<00:10:54.655>We <00:10:54.782>find <00:10:54.909>one <00:10:55.036>in <00:10:55.164>the <00:10:55.291>current <00:10:55.418>scope, <00:10:55.545>its <00:10:55.673>value <00:10:55.800>is <00:10:55.927>currently <00:10:56.055>set

239
00:10:57.235 --> 00:10:59.875
<00:10:57.235>to <00:10:57.375>bs <00:10:57.515>and <00:10:57.655>so <00:10:57.795>we'll <00:10:57.935>change <00:10:58.075>it <00:10:58.215>from <00:10:58.355>BS <00:10:58.495>to <00:10:58.635>BAM.

240
00:11:00.295 --> 00:11:01.595
<00:11:00.295>And <00:11:00.587>then <00:11:00.880>that's <00:11:01.172>console <00:11:01.465>log.

241
00:11:02.455 --> 00:11:05.915
<00:11:02.455>So <00:11:02.610>we <00:11:02.766>console <00:11:02.921>log, <00:11:03.077>bam, <00:11:03.232>leaving <00:11:03.388>this <00:11:03.543>curly <00:11:03.699>brace, <00:11:03.855>uh,

242
00:11:06.005 --> 00:11:08.475
<00:11:06.005>we'll <00:11:06.180>console <00:11:06.355>log <00:11:06.530>that <00:11:06.705>variable <00:11:06.880>again, <00:11:07.055>it's <00:11:07.230>still <00:11:07.405>bam.

243
00:11:09.215 --> 00:11:10.715
<00:11:09.215>And <00:11:09.440>now <00:11:09.665>as <00:11:09.890>we <00:11:10.115>leave <00:11:10.340>the <00:11:10.565>function,

244
00:11:10.715 --> 00:11:13.355
<00:11:10.715>this <00:11:10.995>inner <00:11:11.275>FU <00:11:11.555>is <00:11:11.835>garbage <00:11:12.115>collected

245
00:11:13.655 --> 00:11:16.275
<00:11:13.655>and <00:11:13.888>we'll <00:11:14.121>now <00:11:14.355>console <00:11:14.588>log <00:11:14.821>fu <00:11:15.055>here,

246
00:11:16.685 --> 00:11:18.875
<00:11:16.685>we'll <00:11:16.859>get <00:11:17.035>our <00:11:17.209>outer <00:11:17.385>FU <00:11:17.560>and <00:11:17.734>we'll <00:11:17.910>get <00:11:18.084>bar.

247
00:11:19.575 --> 00:11:23.395
<00:11:19.575>So <00:11:19.702>we <00:11:19.829>get <00:11:19.956>bam, <00:11:20.084>bam <00:11:20.211>and <00:11:20.338>bar. <00:11:20.465>Is <00:11:20.593>that <00:11:20.720>what <00:11:20.847>you <00:11:20.975>got?

248
00:11:25.325 --> 00:11:26.795
<00:11:25.325>Let's <00:11:25.545>do <00:11:25.766>it <00:11:25.986>again. <00:11:26.207>But <00:11:26.427>let's <00:11:26.647>define

249
00:11:26.795 --> 00:11:28.075
<00:11:26.795>our <00:11:27.025>variables <00:11:27.255>a <00:11:27.486>little <00:11:27.716>bit <00:11:27.947>differently.

250
00:11:28.615 --> 00:11:31.595
<00:11:28.615>Now <00:11:28.815>I <00:11:29.015>didn't <00:11:29.215>declare <00:11:29.415>this <00:11:29.615>inner <00:11:29.815>FU <00:11:30.015>variable.

251
00:11:31.955 --> 00:11:36.025
<00:11:31.955>I <00:11:32.110>only <00:11:32.266>declared <00:11:32.421>this <00:11:32.577>outer <00:11:32.732>food <00:11:32.888>variable. <00:11:33.043>What <00:11:33.199>happens <00:11:33.355>here?

252
00:11:39.605 --> 00:11:41.755
<00:11:39.605>Let's <00:11:39.780>think <00:11:39.955>like <00:11:40.130>the <00:11:40.305>compiler <00:11:40.480>and <00:11:40.655>figure <00:11:40.830>it <00:11:41.005>out.

253
00:11:42.295 --> 00:11:45.755
<00:11:42.295>So <00:11:42.469>we <00:11:42.645>start <00:11:42.819>with <00:11:42.995>our <00:11:43.170>first <00:11:43.344>pass <00:11:43.520>allocating <00:11:43.694>variables,

254
00:11:45.755 --> 00:11:47.355
<00:11:45.755>there's <00:11:46.105>that <00:11:46.455>variable <00:11:46.805>to <00:11:47.155>allocate

255
00:11:47.655 --> 00:11:50.635
<00:11:47.655>and <00:11:47.810>now <00:11:47.966>we'll <00:11:48.121>get <00:11:48.277>our <00:11:48.432>second <00:11:48.588>pass <00:11:48.743>to <00:11:48.899>start <00:11:49.055>executing.

256
00:11:51.305 --> 00:11:53.965
<00:11:51.305>Okay, <00:11:51.479>so <00:11:51.655>we'll <00:11:51.829>set <00:11:52.005>that <00:11:52.180>food <00:11:52.354>variable <00:11:52.530>to <00:11:52.704>bar.

257
00:11:54.175 --> 00:11:55.245
<00:11:54.175>We'll <00:11:54.496>define <00:11:54.817>a <00:11:55.138>function

258
00:11:55.265 --> 00:11:56.645
<00:11:55.265>and <00:11:55.679>execute <00:11:56.093>it <00:11:56.507>here

259
00:11:56.665 --> 00:11:59.365
<00:11:56.665>inside <00:11:56.839>this <00:11:57.015>function <00:11:57.189>we'll <00:11:57.365>go <00:11:57.540>find <00:11:57.714>a <00:11:57.890>foo <00:11:58.064>variable.

260
00:12:00.225 --> 00:12:02.605
<00:12:00.225>Now <00:12:00.365>we <00:12:00.505>don't <00:12:00.645>have <00:12:00.785>a <00:12:00.925>foo <00:12:01.065>variable <00:12:01.205>in <00:12:01.345>our <00:12:01.485>current <00:12:01.625>scope.

261
00:12:03.145 --> 00:12:06.005
<00:12:03.145>Uh, <00:12:03.285>actually <00:12:03.425>we <00:12:03.564>do <00:12:03.704>have <00:12:03.845>a <00:12:03.985>foo <00:12:04.125>variable <00:12:04.265>right <00:12:04.405>here. <00:12:04.545>Oops.

262
00:12:06.665 --> 00:12:08.725
<00:12:06.665>So <00:12:06.820>in <00:12:06.976>our <00:12:07.131>first <00:12:07.287>step <00:12:07.442>we <00:12:07.598>would <00:12:07.753>allocate <00:12:07.909>it <00:12:08.064>here.

263
00:12:08.865 --> 00:12:13.605
<00:12:08.865>And <00:12:08.981>here <00:12:09.098>in <00:12:09.215>our <00:12:09.331>second <00:12:09.448>step <00:12:09.565>we <00:12:09.681>would <00:12:09.798>go <00:12:09.915>find <00:12:10.031>our <00:12:10.148>FU <00:12:10.265>variable

264
00:12:13.605 --> 00:12:16.365
<00:12:13.605>in <00:12:13.760>the <00:12:13.916>current <00:12:14.071>scope <00:12:14.227>and <00:12:14.382>we <00:12:14.538>find <00:12:14.693>this <00:12:14.849>F <00:12:15.005>variable

265
00:12:16.365 --> 00:12:17.365
<00:12:16.365>that <00:12:16.665>isn't <00:12:16.965>set <00:12:17.265>yet.

266
00:12:17.415 --> 00:12:20.485
<00:12:17.415>Let's <00:12:17.589>set <00:12:17.765>it <00:12:17.939>to <00:12:18.115>Baz <00:12:18.290>inside <00:12:18.464>this <00:12:18.640>curly <00:12:18.814>brace.

267
00:12:20.695 --> 00:12:22.485
<00:12:20.695>Let's <00:12:20.928>go <00:12:21.161>find <00:12:21.395>that <00:12:21.628>foo <00:12:21.861>variable <00:12:22.095>again,

268
00:12:22.575 --> 00:12:24.085
<00:12:22.575>we'll <00:12:22.846>set <00:12:23.118>its <00:12:23.390>value <00:12:23.662>to <00:12:23.934>BAM.

269
00:12:24.265 --> 00:12:27.045
<00:12:24.265>And <00:12:24.405>now <00:12:24.545>we'll <00:12:24.685>console <00:12:24.824>log, <00:12:24.965>bam, <00:12:25.105>we'll <00:12:25.245>console, <00:12:25.385>log <00:12:25.525>it <00:12:25.665>again

270
00:12:27.465 --> 00:12:30.605
<00:12:27.465>and <00:12:27.698>leaving <00:12:27.931>this <00:12:28.165>uh, <00:12:28.398>function <00:12:28.631>we'll <00:12:28.865>console,

271
00:12:30.745 --> 00:12:35.645
<00:12:30.745>log <00:12:30.852>the <00:12:30.960>outer <00:12:31.068>FU <00:12:31.175>here <00:12:31.283>as <00:12:31.391>bar <00:12:31.498>so <00:12:31.606>we <00:12:31.714>get <00:12:31.821>bam, <00:12:31.929>bam <00:12:32.037>and <00:12:32.145>bar.

272
00:12:38.185 --> 00:12:43.125
<00:12:38.185>Is <00:12:38.359>that <00:12:38.535>what <00:12:38.709>you <00:12:38.885>got? <00:12:39.060>Let's <00:12:39.234>do <00:12:39.410>it <00:12:39.584>again.

273
00:12:43.265 --> 00:12:45.205
<00:12:43.265>But <00:12:43.439>in <00:12:43.615>this <00:12:43.790>case <00:12:43.965>we <00:12:44.140>won't <00:12:44.314>define <00:12:44.490>it <00:12:44.665>here

274
00:12:45.265 --> 00:12:46.405
<00:12:45.265>and <00:12:45.470>we <00:12:45.675>won't <00:12:45.880>define <00:12:46.085>it <00:12:46.290>here.

275
00:12:46.405 --> 00:12:47.605
<00:12:46.405>We'll <00:12:46.621>only <00:12:46.837>define <00:12:47.053>it <00:12:47.269>out <00:12:47.485>here.

276
00:12:48.275 --> 00:12:49.905
<00:12:48.275>What <00:12:48.625>happens <00:12:48.975>in <00:12:49.324>this <00:12:49.675>case,

277
00:12:52.935 --> 00:12:55.125
<00:12:52.935>let's <00:12:53.109>think <00:12:53.285>like <00:12:53.459>the <00:12:53.635>compiler <00:12:53.810>and <00:12:53.984>figure <00:12:54.160>it <00:12:54.334>out.

278
00:12:55.225 --> 00:12:57.125
<00:12:55.225>Our <00:12:55.458>first <00:12:55.691>pass <00:12:55.925>is <00:12:56.158>to <00:12:56.391>allocate <00:12:56.625>variables.

279
00:12:57.345 --> 00:12:59.085
<00:12:57.345>We <00:12:57.578>only <00:12:57.811>have <00:12:58.045>one <00:12:58.278>foo <00:12:58.511>variable <00:12:58.745>out

280
00:12:59.085 --> 00:13:00.365
<00:12:59.085>here, <00:12:59.373>so <00:12:59.661>let's <00:12:59.949>allocate <00:13:00.237>it.

281
00:13:01.085 --> 00:13:03.465
<00:13:01.085>Second <00:13:01.365>pass. <00:13:01.645>Let's <00:13:01.925>start <00:13:02.205>executing <00:13:02.485>things.

282
00:13:03.765 --> 00:13:05.825
<00:13:03.765>So <00:13:03.965>we'll <00:13:04.165>set <00:13:04.365>our <00:13:04.564>foo <00:13:04.765>variable <00:13:04.965>to <00:13:05.165>bar.

283
00:13:06.085 --> 00:13:08.225
<00:13:06.085>We <00:13:06.260>will <00:13:06.435>define <00:13:06.610>our <00:13:06.785>bar <00:13:06.960>function <00:13:07.135>and <00:13:07.310>execute <00:13:07.485>it.

284
00:13:08.565 --> 00:13:11.625
<00:13:08.565>Now <00:13:08.798>inside <00:13:09.031>that <00:13:09.265>uh <00:13:09.498>function <00:13:09.731>we're <00:13:09.965>going

285
00:13:11.625 --> 00:13:12.985
<00:13:11.625>to <00:13:11.869>look <00:13:12.114>for <00:13:12.359>a <00:13:12.604>foo <00:13:12.849>variable.

286
00:13:13.405 --> 00:13:15.425
<00:13:13.405>Now <00:13:13.560>we <00:13:13.716>don't <00:13:13.871>have <00:13:14.027>any <00:13:14.182>defined <00:13:14.338>in <00:13:14.493>the <00:13:14.649>current <00:13:14.805>scope,

287
00:13:15.485 --> 00:13:16.665
<00:13:15.485>so <00:13:15.697>we'll <00:13:15.909>climb <00:13:16.122>up <00:13:16.334>a <00:13:16.547>scope

288
00:13:16.885 --> 00:13:18.585
<00:13:16.885>and <00:13:17.085>we <00:13:17.285>do <00:13:17.485>find <00:13:17.685>a <00:13:17.885>foo <00:13:18.085>variable <00:13:18.285>here.

289
00:13:19.165 --> 00:13:23.945
<00:13:19.165>So <00:13:19.272>what <00:13:19.380>was <00:13:19.488>bar <00:13:19.595>we'll <00:13:19.703>now <00:13:19.811>set <00:13:19.918>to <00:13:20.026>BS <00:13:20.134>if <00:13:20.241>true? <00:13:20.349>Let's <00:13:20.457>go <00:13:20.564>set.

290
00:13:23.945 --> 00:13:27.025
<00:13:23.945>What <00:13:24.120>was <00:13:24.295>bs <00:13:24.470>tl? <00:13:24.645>BAM <00:13:24.820>and <00:13:24.995>we'll <00:13:25.170>console <00:13:25.345>log.

291
00:13:27.165 --> 00:13:30.705
<00:13:27.165>Bam, <00:13:27.320>leaving <00:13:27.476>the <00:13:27.631>curly <00:13:27.787>brace, <00:13:27.942>we'll <00:13:28.098>console <00:13:28.253>log <00:13:28.409>BAM <00:13:28.564>again

292
00:13:31.085 --> 00:13:33.825
<00:13:31.085>and <00:13:31.260>leaving <00:13:31.435>our <00:13:31.610>function <00:13:31.785>we'll <00:13:31.960>console <00:13:32.135>log <00:13:32.310>FU <00:13:32.485>again,

293
00:13:33.875 --> 00:13:35.785
<00:13:33.875>we're <00:13:34.108>still <00:13:34.341>after <00:13:34.575>this <00:13:34.808>one <00:13:35.041>FU <00:13:35.275>variable

294
00:13:35.925 --> 00:13:37.025
<00:13:35.925>and <00:13:36.255>we'll <00:13:36.584>console <00:13:36.915>log.

295
00:13:37.125 --> 00:13:39.225
<00:13:37.125>Bam. <00:13:37.325>Third <00:13:37.525>time, <00:13:37.725>is <00:13:37.925>that <00:13:38.125>what <00:13:38.325>you <00:13:38.525>got?

296
00:13:41.655 --> 00:13:43.965
<00:13:41.655>Let's <00:13:41.795>do <00:13:41.935>it <00:13:42.074>again. <00:13:42.214>But <00:13:42.355>in <00:13:42.495>this <00:13:42.635>case <00:13:42.775>we're <00:13:42.915>not <00:13:43.055>gonna

297
00:13:43.965 --> 00:13:45.365
<00:13:43.965>define <00:13:44.595>any <00:13:45.225>variables.

298
00:13:46.275 --> 00:13:51.145
<00:13:46.275>What <00:13:46.555>happens <00:13:46.834>here? <00:13:47.115>Let's <00:13:47.395>think <00:13:47.675>like

299
00:13:51.145 --> 00:13:52.465
<00:13:51.145>the <00:13:51.382>compiler <00:13:51.620>and <00:13:51.857>figure <00:13:52.095>it <00:13:52.333>out.

300
00:13:53.505 --> 00:13:55.265
<00:13:53.505>Okay, <00:13:53.705>our <00:13:53.905>first <00:13:54.105>step <00:13:54.305>is <00:13:54.505>to <00:13:54.705>allocate <00:13:54.905>variables

301
00:13:55.265 --> 00:13:57.865
<00:13:55.265>and <00:13:55.545>there <00:13:55.824>aren't <00:13:56.105>any <00:13:56.385>next <00:13:56.665>step.

302
00:13:58.275 --> 00:13:59.585
<00:13:58.275>Let's <00:13:58.569>go <00:13:58.864>execute <00:13:59.159>the <00:13:59.454>code.

303
00:14:00.045 --> 00:14:02.865
<00:14:00.045>Now <00:14:00.161>our <00:14:00.278>first <00:14:00.395>task <00:14:00.511>is <00:14:00.628>to <00:14:00.745>set <00:14:00.861>this <00:14:00.978>foo <00:14:01.094>variable <00:14:01.211>equal <00:14:01.328>to <00:14:01.444>bar.

304
00:14:03.075 --> 00:14:04.625
<00:14:03.075>Let's <00:14:03.307>go <00:14:03.540>looking <00:14:03.772>for <00:14:04.005>a <00:14:04.237>foo <00:14:04.470>variable.

305
00:14:04.625 --> 00:14:06.465
<00:14:04.625>In <00:14:04.825>the <00:14:05.025>current <00:14:05.225>scope, <00:14:05.425>we <00:14:05.625>don't <00:14:05.825>see <00:14:06.025>one.

306
00:14:06.845 --> 00:14:08.385
<00:14:06.845>We <00:14:07.122>can <00:14:07.399>climb <00:14:07.676>up <00:14:07.953>the <00:14:08.231>scopes

307
00:14:08.385 --> 00:14:09.905
<00:14:08.385>and <00:14:08.580>eventually <00:14:08.775>we'll <00:14:08.971>get <00:14:09.166>to <00:14:09.362>the <00:14:09.557>global <00:14:09.752>scope.

308
00:14:10.075 --> 00:14:12.305
<00:14:10.075>Let's <00:14:10.250>assume <00:14:10.425>that <00:14:10.600>we <00:14:10.775>don't <00:14:10.950>find <00:14:11.125>one <00:14:11.300>there <00:14:11.475>either.

309
00:14:13.165 --> 00:14:16.145
<00:14:13.165>So <00:14:13.339>now <00:14:13.515>we're <00:14:13.689>gonna <00:14:13.865>declare <00:14:14.040>a <00:14:14.214>new <00:14:14.390>global <00:14:14.564>variable.

310
00:14:16.395 --> 00:14:17.545
<00:14:16.395>JavaScript <00:14:16.912>is <00:14:17.430>trying

311
00:14:17.545 --> 00:14:19.705
<00:14:17.545>to <00:14:17.719>keep <00:14:17.895>our <00:14:18.069>code <00:14:18.245>running <00:14:18.420>as <00:14:18.594>much <00:14:18.770>as <00:14:18.944>possible.

312
00:14:19.725 --> 00:14:20.985
<00:14:19.725>The <00:14:20.008>developer <00:14:20.292>has <00:14:20.575>already <00:14:20.859>left

313
00:14:21.205 --> 00:14:23.105
<00:14:21.205>so <00:14:21.485>it's <00:14:21.765>automatically <00:14:22.045>gonna <00:14:22.325>create <00:14:22.605>this

314
00:14:23.165 --> 00:14:24.585
<00:14:23.165>foo <00:14:23.420>variable <00:14:23.676>in <00:14:23.931>the <00:14:24.187>global <00:14:24.443>scope.

315
00:14:24.885 --> 00:14:26.265
<00:14:24.885>Now <00:14:25.062>we <00:14:25.239>can <00:14:25.417>set <00:14:25.594>its <00:14:25.772>value <00:14:25.949>to <00:14:26.127>bar.

316
00:14:26.885 --> 00:14:29.235
<00:14:26.885>Great, <00:14:27.235>our <00:14:27.585>program <00:14:27.935>didn't <00:14:28.285>crash.

317
00:14:29.285 --> 00:14:31.275
<00:14:29.285>JavaScript <00:14:29.485>was <00:14:29.685>able <00:14:29.885>to <00:14:30.084>save <00:14:30.285>us <00:14:30.485>from <00:14:30.685>that.

318
00:14:32.095 --> 00:14:34.395
<00:14:32.095>Now <00:14:32.295>let's <00:14:32.495>define <00:14:32.695>the <00:14:32.895>function <00:14:33.095>and <00:14:33.295>execute <00:14:33.495>it.

319
00:14:34.815 --> 00:14:37.755
<00:14:34.815>And <00:14:34.942>so <00:14:35.069>now <00:14:35.196>here <00:14:35.324>we're <00:14:35.451>gonna <00:14:35.578>go <00:14:35.705>looking <00:14:35.833>for <00:14:35.960>a <00:14:36.087>foo <00:14:36.215>variable.

320
00:14:37.905 --> 00:14:40.235
<00:14:37.905>There's <00:14:38.079>no <00:14:38.255>foo <00:14:38.430>variable <00:14:38.605>defined <00:14:38.780>in <00:14:38.954>our <00:14:39.130>current <00:14:39.305>scope.

321
00:14:40.545 --> 00:14:42.915
<00:14:40.545>None <00:14:40.685>in <00:14:40.824>the <00:14:40.964>outer <00:14:41.104>scope, <00:14:41.245>none <00:14:41.385>in <00:14:41.525>any <00:14:41.665>of <00:14:41.805>the <00:14:41.944>scopes

322
00:14:42.925 --> 00:14:45.075
<00:14:42.925>until <00:14:43.080>we <00:14:43.236>get <00:14:43.391>to <00:14:43.547>the <00:14:43.702>global <00:14:43.858>scope <00:14:44.013>where <00:14:44.169>we <00:14:44.324>get

323
00:14:45.075 --> 00:14:47.595
<00:14:45.075>that <00:14:45.250>foo <00:14:45.425>variable <00:14:45.600>that <00:14:45.775>was <00:14:45.950>defined <00:14:46.125>with <00:14:46.300>this <00:14:46.475>statement.

324
00:14:48.095 --> 00:14:50.555
<00:14:48.095>So <00:14:48.295>what <00:14:48.495>was <00:14:48.695>Barr <00:14:48.895>will <00:14:49.095>now <00:14:49.295>become <00:14:49.495>Baz.

325
00:14:51.345 --> 00:14:54.725
<00:14:51.345>Now <00:14:51.472>we'll <00:14:51.599>go <00:14:51.726>find <00:14:51.854>that <00:14:51.981>global <00:14:52.108>variable <00:14:52.235>again, <00:14:52.363>set <00:14:52.490>it <00:14:52.617>to <00:14:52.745>BAM

326
00:14:54.825 --> 00:14:56.685
<00:14:54.825>and <00:14:55.058>we'll <00:14:55.291>console <00:14:55.525>log <00:14:55.758>bam <00:14:55.991>three <00:14:56.225>times.

327
00:14:58.825 --> 00:15:00.755
<00:14:58.825>That <00:14:59.000>was <00:14:59.175>pretty <00:14:59.350>cool. <00:14:59.525>Is <00:14:59.700>that <00:14:59.875>what <00:15:00.050>you <00:15:00.225>got?

328
00:15:03.775 --> 00:15:06.845
<00:15:03.775>Let's <00:15:03.891>do <00:15:04.008>it <00:15:04.125>again. <00:15:04.241>But <00:15:04.358>in <00:15:04.475>this <00:15:04.591>case <00:15:04.708>we're <00:15:04.824>gonna <00:15:04.941>set <00:15:05.058>food <00:15:05.175>not

329
00:15:06.845 --> 00:15:09.045
<00:15:06.845>to <00:15:07.045>a <00:15:07.245>string <00:15:07.445>but <00:15:07.645>to <00:15:07.845>this <00:15:08.045>bam <00:15:08.245>variable.

330
00:15:09.395 --> 00:15:10.645
<00:15:09.395>What <00:15:09.676>happens <00:15:09.957>in <00:15:10.238>this <00:15:10.520>case,

331
00:15:13.675 --> 00:15:15.865
<00:15:13.675>let's <00:15:13.849>think <00:15:14.025>like <00:15:14.199>the <00:15:14.375>compiler <00:15:14.550>and <00:15:14.724>figure <00:15:14.900>it <00:15:15.074>out.

332
00:15:16.005 --> 00:15:17.865
<00:15:16.005>Our <00:15:16.238>first <00:15:16.471>task <00:15:16.705>is <00:15:16.938>to <00:15:17.171>allocate <00:15:17.405>variables

333
00:15:17.865 --> 00:15:20.185
<00:15:17.865>and <00:15:18.020>we've <00:15:18.176>got <00:15:18.331>this <00:15:18.487>food <00:15:18.642>variable <00:15:18.798>that <00:15:18.953>we'll <00:15:19.109>allocate <00:15:19.265>here.

334
00:15:20.725 --> 00:15:22.265
<00:15:20.725>Our <00:15:21.002>next <00:15:21.279>task <00:15:21.556>is <00:15:21.833>to <00:15:22.111>execute.

335
00:15:23.035 --> 00:15:24.705
<00:15:23.035>We'll <00:15:23.268>set <00:15:23.501>that <00:15:23.735>food <00:15:23.968>variable <00:15:24.201>to <00:15:24.435>bar.

336
00:15:24.925 --> 00:15:27.185
<00:15:24.925>We <00:15:25.158>will <00:15:25.391>define <00:15:25.625>and <00:15:25.858>execute <00:15:26.091>this <00:15:26.324>function.

337
00:15:27.435 --> 00:15:29.705
<00:15:27.435>Let's <00:15:27.635>set <00:15:27.834>what <00:15:28.035>was <00:15:28.234>bar <00:15:28.435>to <00:15:28.635>be <00:15:28.834>bs

338
00:15:30.085 --> 00:15:32.265
<00:15:30.085>and <00:15:30.260>then <00:15:30.435>inside <00:15:30.610>this <00:15:30.785>if <00:15:30.960>block <00:15:31.135>we're <00:15:31.310>gonna <00:15:31.485>try

339
00:15:32.265 --> 00:15:34.105
<00:15:32.265>and <00:15:32.545>go <00:15:32.824>find <00:15:33.105>a <00:15:33.385>BAM <00:15:33.665>variable.

340
00:15:34.845 --> 00:15:36.945
<00:15:34.845>Now <00:15:34.985>we <00:15:35.125>don't <00:15:35.265>have <00:15:35.405>a <00:15:35.545>BAM <00:15:35.685>variable <00:15:35.825>in <00:15:35.965>our <00:15:36.105>current <00:15:36.245>scope.

341
00:15:37.205 --> 00:15:39.145
<00:15:37.205>We <00:15:37.405>don't <00:15:37.605>have <00:15:37.805>one <00:15:38.005>in <00:15:38.205>our <00:15:38.405>outer <00:15:38.605>scope.

342
00:15:39.365 --> 00:15:41.185
<00:15:39.365>We <00:15:39.540>don't <00:15:39.715>even <00:15:39.890>have <00:15:40.065>one <00:15:40.240>in <00:15:40.415>our <00:15:40.590>global <00:15:40.765>scope.

343
00:15:42.335 --> 00:15:45.675
<00:15:42.335>So <00:15:42.451>how <00:15:42.568>do <00:15:42.685>I <00:15:42.801>get <00:15:42.918>the <00:15:43.035>value <00:15:43.151>out <00:15:43.268>of <00:15:43.385>bam? <00:15:43.501>Well <00:15:43.618>we <00:15:43.735>can't.

344
00:15:45.825 --> 00:15:48.595
<00:15:45.825>That <00:15:45.980>variable <00:15:46.136>doesn't <00:15:46.291>exist <00:15:46.447>and <00:15:46.602>we <00:15:46.758>get <00:15:46.913>a <00:15:47.069>reference <00:15:47.225>error.

345
00:15:48.815 --> 00:15:51.205
<00:15:48.815>BAM <00:15:49.048>is <00:15:49.281>not <00:15:49.515>defined. <00:15:49.748>Wait <00:15:49.981>a <00:15:50.215>minute.

346
00:15:51.755 --> 00:15:54.845
<00:15:51.755>When <00:15:51.910>we're <00:15:52.066>setting <00:15:52.221>a <00:15:52.377>variable <00:15:52.532>we <00:15:52.688>could <00:15:52.843>just <00:15:52.999>set <00:15:53.155>it

347
00:15:54.845 --> 00:15:57.605
<00:15:54.845>and <00:15:55.020>everything <00:15:55.195>worked <00:15:55.370>great <00:15:55.545>when <00:15:55.720>we're <00:15:55.895>getting <00:15:56.070>a <00:15:56.245>variable

348
00:15:57.605 --> 00:15:58.965
<00:15:57.605>that <00:15:57.911>doesn't <00:15:58.217>exist <00:15:58.523>at <00:15:58.829>errors.

349
00:15:59.505 --> 00:16:03.905
<00:15:59.505>Why <00:15:59.680>is <00:15:59.855>that <00:16:00.030>different? <00:16:00.205>Uh, <00:16:00.380>yeah <00:16:00.555>that <00:16:00.730>is <00:16:00.905>different.

350
00:16:04.125 --> 00:16:06.945
<00:16:04.125>But <00:16:04.241>in <00:16:04.358>this <00:16:04.475>case <00:16:04.591>we're <00:16:04.708>trying <00:16:04.825>to <00:16:04.941>get <00:16:05.058>a <00:16:05.175>value <00:16:05.291>from <00:16:05.408>a <00:16:05.525>variable

351
00:16:06.945 --> 00:16:09.145
<00:16:06.945>that <00:16:07.120>doesn't <00:16:07.295>exist <00:16:07.470>and <00:16:07.645>there <00:16:07.820>is <00:16:07.995>no <00:16:08.170>such <00:16:08.345>variable

352
00:16:09.255 --> 00:16:11.185
<00:16:09.255>therefore <00:16:09.535>we <00:16:09.814>have <00:16:10.095>no <00:16:10.375>such <00:16:10.655>value.

353
00:16:11.715 --> 00:16:13.465
<00:16:11.715>Maybe <00:16:12.181>JavaScript <00:16:12.648>could <00:16:13.115>allocate

354
00:16:13.525 --> 00:16:16.185
<00:16:13.525>and <00:16:13.758>set <00:16:13.991>a <00:16:14.225>value <00:16:14.458>to <00:16:14.691>undefined <00:16:14.925>maybe,

355
00:16:17.045 --> 00:16:19.305
<00:16:17.045>but <00:16:17.245>in <00:16:17.444>this <00:16:17.645>case <00:16:17.844>it <00:16:18.045>chooses <00:16:18.245>to <00:16:18.444>error.

356
00:16:21.225 --> 00:16:22.555
<00:16:21.225>That <00:16:21.524>is <00:16:21.823>weird <00:16:22.122>that <00:16:22.421>get

357
00:16:22.575 --> 00:16:25.275
<00:16:22.575>and <00:16:22.775>set <00:16:22.975>for <00:16:23.175>an <00:16:23.375>undefined <00:16:23.575>variable <00:16:23.775>behaves <00:16:23.975>differently.

358
00:16:25.575 --> 00:16:27.235
<00:16:25.575>But <00:16:25.808>as <00:16:26.041>we <00:16:26.275>think <00:16:26.508>like <00:16:26.741>the <00:16:26.975>compiler,

359
00:16:27.235 --> 00:16:28.555
<00:16:27.235>we <00:16:27.472>can <00:16:27.710>start <00:16:27.947>to <00:16:28.185>understand <00:16:28.423>why.

360
00:16:29.305 --> 00:16:33.575
<00:16:29.305>That's <00:16:29.505>great. <00:16:29.704>Okay, <00:16:29.905>so <00:16:30.104>now <00:16:30.305>let's <00:16:30.505>define <00:16:30.704>this.

361
00:16:33.745 --> 00:16:35.135
<00:16:33.745>We've <00:16:34.057>got <00:16:34.370>FU <00:16:34.683>and <00:16:34.996>fu

362
00:16:35.395 --> 00:16:37.975
<00:16:35.395>but <00:16:35.550>in <00:16:35.706>this <00:16:35.861>case, <00:16:36.017>instead <00:16:36.172>of <00:16:36.328>defining <00:16:36.483>them <00:16:36.639>as <00:16:36.795>variables,

363
00:16:38.185 --> 00:16:42.455
<00:16:38.185>we're <00:16:38.312>gonna <00:16:38.439>define <00:16:38.566>them <00:16:38.694>as <00:16:38.821>let <00:16:38.948>Let <00:16:39.075>is <00:16:39.203>new <00:16:39.330>in <00:16:39.457>ES <00:16:39.584>six

364
00:16:42.475 --> 00:16:43.575
<00:16:42.475>or <00:16:42.805>E <00:16:43.135>ES <00:16:43.465>2015

365
00:16:43.795 --> 00:16:45.375
<00:16:43.795>and <00:16:44.074>allows <00:16:44.354>us <00:16:44.635>to <00:16:44.915>define <00:16:45.194>variables

366
00:16:45.375 --> 00:16:48.455
<00:16:45.375>that <00:16:45.550>have <00:16:45.725>curly <00:16:45.900>brace <00:16:46.075>scope, <00:16:46.250>not <00:16:46.425>function <00:16:46.600>level <00:16:46.775>scope.

367
00:16:49.075 --> 00:16:52.615
<00:16:49.075>So <00:16:49.202>if <00:16:49.329>you're <00:16:49.456>coming <00:16:49.584>from <00:16:49.711>C <00:16:49.838>or <00:16:49.965>C <00:16:50.093>plus <00:16:50.220>plus <00:16:50.347>C <00:16:50.475>sharp

368
00:16:52.635 --> 00:16:54.655
<00:16:52.635>or <00:16:52.835>Java, <00:16:53.035>it <00:16:53.235>may <00:16:53.435>feel <00:16:53.635>more <00:16:53.835>at <00:16:54.035>home.

369
00:16:55.525 --> 00:16:56.695
<00:16:55.525>What <00:16:55.788>happens <00:16:56.051>in <00:16:56.314>this <00:16:56.578>case,

370
00:17:00.205 --> 00:17:02.355
<00:17:00.205>let's <00:17:00.380>think <00:17:00.555>like <00:17:00.730>the <00:17:00.905>compiler <00:17:01.080>and <00:17:01.255>figure <00:17:01.430>it <00:17:01.605>out.

371
00:17:02.655 --> 00:17:04.555
<00:17:02.655>Our <00:17:02.888>first <00:17:03.121>pass <00:17:03.355>is <00:17:03.588>to <00:17:03.821>allocate <00:17:04.055>variables.

372
00:17:04.685 --> 00:17:07.235
<00:17:04.685>We've <00:17:04.812>got <00:17:04.939>an <00:17:05.066>outer <00:17:05.194>F <00:17:05.321>here, <00:17:05.448>we've <00:17:05.575>got <00:17:05.703>an <00:17:05.830>inner <00:17:05.957>FU <00:17:06.085>here

373
00:17:07.415 --> 00:17:09.235
<00:17:07.415>and <00:17:07.615>we'll <00:17:07.815>set <00:17:08.014>both <00:17:08.214>of <00:17:08.415>those <00:17:08.615>variables <00:17:08.815>aside.

374
00:17:10.715 --> 00:17:12.165
<00:17:10.714>Next, <00:17:11.367>let's <00:17:12.020>execute.

375
00:17:12.745 --> 00:17:15.765
<00:17:12.744>So <00:17:12.885>our <00:17:13.024>outer <00:17:13.165>fu, <00:17:13.304>we'll <00:17:13.444>set <00:17:13.584>it <00:17:13.724>to <00:17:13.864>bar, <00:17:14.004>that's <00:17:14.145>great.

376
00:17:15.895 --> 00:17:18.365
<00:17:15.895>We'll <00:17:16.095>define <00:17:16.295>and <00:17:16.494>then <00:17:16.694>execute <00:17:16.895>a <00:17:17.095>function <00:17:17.295>here

377
00:17:18.365 --> 00:17:20.405
<00:17:18.365>inside <00:17:18.598>the <00:17:18.831>bar <00:17:19.065>function <00:17:19.298>we're <00:17:19.531>going <00:17:19.765>looking

378
00:17:20.425 --> 00:17:21.485
<00:17:20.425>for <00:17:20.742>this <00:17:21.060>FU <00:17:21.378>variable.

379
00:17:22.305 --> 00:17:24.965
<00:17:22.305>Now <00:17:22.538>with <00:17:22.771>let <00:17:23.005>variables, <00:17:23.238>they're <00:17:23.471>defined <00:17:23.705>at

380
00:17:25.495 --> 00:17:27.605
<00:17:25.494>curly <00:17:25.728>brace <00:17:25.961>scope, <00:17:26.194>not <00:17:26.428>function <00:17:26.661>level <00:17:26.895>scope.

381
00:17:27.865 --> 00:17:30.645
<00:17:27.865>So <00:17:28.040>this <00:17:28.214>FU <00:17:28.390>variable <00:17:28.565>is <00:17:28.740>not <00:17:28.915>in <00:17:29.090>scope <00:17:29.265>yet,

382
00:17:31.265 --> 00:17:33.605
<00:17:31.265>so <00:17:31.440>there's <00:17:31.615>no <00:17:31.790>FU <00:17:31.965>variables <00:17:32.140>in <00:17:32.315>our <00:17:32.490>current <00:17:32.665>scope.

383
00:17:33.655 --> 00:17:35.205
<00:17:33.655>We'll <00:17:33.934>reach <00:17:34.213>into <00:17:34.492>our <00:17:34.771>outer <00:17:35.050>scope

384
00:17:35.265 --> 00:17:36.925
<00:17:35.265>and <00:17:35.498>we <00:17:35.731>have <00:17:35.965>this <00:17:36.198>FU <00:17:36.431>variable <00:17:36.665>here.

385
00:17:37.295 --> 00:17:40.485
<00:17:37.295>Let's <00:17:37.450>use <00:17:37.606>it. <00:17:37.761>So <00:17:37.917>what <00:17:38.072>was <00:17:38.228>bar <00:17:38.383>is <00:17:38.539>now <00:17:38.695>Bs

386
00:17:41.505 --> 00:17:43.005
<00:17:41.505>inside <00:17:41.955>this <00:17:42.405>true <00:17:42.855>block.

387
00:17:43.265 --> 00:17:46.845
<00:17:43.265>We <00:17:43.420>now <00:17:43.576>define <00:17:43.731>this <00:17:43.887>new <00:17:44.042>FU <00:17:44.198>inner <00:17:44.353>FU <00:17:44.509>as <00:17:44.665>bam.

388
00:17:46.905 --> 00:17:50.365
<00:17:46.905>And <00:17:47.080>we'll <00:17:47.254>console <00:17:47.430>log <00:17:47.605>BA <00:17:47.780>leaving <00:17:47.955>the <00:17:48.129>IF <00:17:48.305>block.

389
00:17:50.625 --> 00:17:53.205
<00:17:50.625>We <00:17:50.825>now <00:17:51.025>go <00:17:51.225>looking <00:17:51.425>for <00:17:51.625>our <00:17:51.825>food <00:17:52.025>variable.

390
00:17:53.205 --> 00:17:54.445
<00:17:53.205>There's <00:17:53.428>none <00:17:53.651>in <00:17:53.874>our <00:17:54.097>current <00:17:54.321>scope

391
00:17:54.465 --> 00:17:56.125
<00:17:54.465>but <00:17:54.698>we'll <00:17:54.931>find <00:17:55.165>this <00:17:55.398>outer <00:17:55.631>F <00:17:55.865>variable.

392
00:17:56.465 --> 00:17:57.605
<00:17:56.465>So <00:17:56.807>what <00:17:57.149>was <00:17:57.491>B?

393
00:17:57.945 --> 00:17:59.125
<00:17:57.945>We <00:17:58.210>will <00:17:58.476>console <00:17:58.741>log <00:17:59.007>here

394
00:17:59.665 --> 00:18:02.045
<00:17:59.665>and <00:17:59.840>then <00:18:00.014>leaving <00:18:00.190>our <00:18:00.365>scope <00:18:00.540>we <00:18:00.715>will <00:18:00.889>console <00:18:01.065>log

395
00:18:02.045 --> 00:18:05.445
<00:18:02.045>that <00:18:02.172>variable <00:18:02.299>again <00:18:02.426>and <00:18:02.554>so <00:18:02.681>we <00:18:02.808>will <00:18:02.935>get <00:18:03.063>bam, <00:18:03.190>Baz <00:18:03.317>and <00:18:03.445>B.

396
00:18:06.645 --> 00:18:07.745
<00:18:06.645>Is <00:18:06.892>that <00:18:07.139>what <00:18:07.387>you <00:18:07.635>got?

397
00:18:10.315 --> 00:18:13.575
<00:18:10.315>Now <00:18:10.490>instead <00:18:10.665>of <00:18:10.840>uh, <00:18:11.015>defining <00:18:11.190>this <00:18:11.365>outer <00:18:11.540>foo <00:18:11.715>variable,

398
00:18:13.585 --> 00:18:15.055
<00:18:13.585>we're <00:18:13.849>gonna <00:18:14.114>comment <00:18:14.378>that <00:18:14.643>one <00:18:14.908>out.

399
00:18:15.355 --> 00:18:16.695
<00:18:15.355>And <00:18:15.596>let's <00:18:15.837>see <00:18:16.078>what <00:18:16.319>happens <00:18:16.561>here.

400
00:18:20.595 --> 00:18:23.695
<00:18:20.595>In <00:18:20.735>our <00:18:20.875>first <00:18:21.015>pass, <00:18:21.155>we <00:18:21.295>go <00:18:21.435>looking <00:18:21.575>for <00:18:21.715>variables <00:18:21.855>to <00:18:21.995>allocate

401
00:18:23.715 --> 00:18:25.535
<00:18:23.715>and <00:18:23.915>we <00:18:24.115>have <00:18:24.314>this <00:18:24.514>foo <00:18:24.715>variable <00:18:24.915>right <00:18:25.115>here.

402
00:18:25.875 --> 00:18:27.935
<00:18:25.875>And <00:18:26.050>then <00:18:26.225>in <00:18:26.400>our <00:18:26.575>second <00:18:26.750>pass <00:18:26.925>we're <00:18:27.100>gonna <00:18:27.275>start

403
00:18:27.935 --> 00:18:30.375
<00:18:27.935>to <00:18:28.215>assign <00:18:28.495>things, <00:18:28.774>our <00:18:29.054>execute <00:18:29.335>things.

404
00:18:30.525 --> 00:18:32.335
<00:18:30.525>There's <00:18:30.758>nothing <00:18:30.991>here. <00:18:31.225>This <00:18:31.458>is <00:18:31.691>a <00:18:31.925>comment.

405
00:18:32.475 --> 00:18:34.535
<00:18:32.475>So <00:18:32.675>we'll <00:18:32.875>define <00:18:33.074>and <00:18:33.274>then <00:18:33.475>execute <00:18:33.675>our <00:18:33.875>function.

406
00:18:34.915 --> 00:18:36.895
<00:18:34.915>Now <00:18:35.090>we're <00:18:35.264>going <00:18:35.440>to <00:18:35.615>look <00:18:35.790>for <00:18:35.965>a <00:18:36.139>food <00:18:36.315>variable

407
00:18:36.895 --> 00:18:37.935
<00:18:36.895>that <00:18:37.129>we <00:18:37.363>want <00:18:37.597>to <00:18:37.831>set.

408
00:18:38.855 --> 00:18:40.505
<00:18:38.855>Well <00:18:39.088>there's <00:18:39.321>none <00:18:39.555>in <00:18:39.788>the <00:18:40.021>current <00:18:40.255>scope.

409
00:18:40.575 --> 00:18:42.265
<00:18:40.575>This <00:18:40.808>one <00:18:41.041>is <00:18:41.275>inside <00:18:41.508>this <00:18:41.741>curly <00:18:41.975>brace.

410
00:18:42.265 --> 00:18:43.705
<00:18:42.265>So <00:18:42.481>it <00:18:42.697>isn't <00:18:42.913>available <00:18:43.129>to <00:18:43.345>us <00:18:43.561>yet.

411
00:18:43.885 --> 00:18:45.185
<00:18:43.885>We <00:18:44.052>don't <00:18:44.219>have <00:18:44.386>one <00:18:44.553>in <00:18:44.720>the <00:18:44.887>outer <00:18:45.054>scope.

412
00:18:45.445 --> 00:18:48.105
<00:18:45.445>So <00:18:45.620>we're <00:18:45.794>gonna <00:18:45.970>define <00:18:46.145>one <00:18:46.320>in <00:18:46.495>the <00:18:46.669>global <00:18:46.845>scope.

413
00:18:48.125 --> 00:18:49.905
<00:18:48.125>Thanks <00:18:48.475>JavaScript <00:18:48.825>for <00:18:49.175>helping <00:18:49.525>us.

414
00:18:50.645 --> 00:18:52.745
<00:18:50.645>So <00:18:50.845>we <00:18:51.045>set <00:18:51.245>that <00:18:51.445>FU <00:18:51.645>variable <00:18:51.845>to <00:18:52.045>Baz.

415
00:18:53.005 --> 00:18:55.585
<00:18:53.005>Inside <00:18:53.160>this <00:18:53.316>curly <00:18:53.471>brace <00:18:53.627>we <00:18:53.782>have <00:18:53.938>our <00:18:54.093>new <00:18:54.249>FU <00:18:54.405>variable.

416
00:18:55.835 --> 00:18:58.025
<00:18:55.835>We'll <00:18:56.010>set <00:18:56.185>that <00:18:56.360>to <00:18:56.535>bam. <00:18:56.710>Here's <00:18:56.885>our <00:18:57.060>inner <00:18:57.235>fu.

417
00:18:58.605 --> 00:19:02.065
<00:18:58.605>So <00:18:58.760>we'll <00:18:58.916>console <00:18:59.071>log <00:18:59.227>bam <00:18:59.382>out <00:18:59.538>of <00:18:59.693>our <00:18:59.849>IF <00:19:00.005>block.

418
00:19:02.165 --> 00:19:03.825
<00:19:02.165>Now <00:19:02.398>we're <00:19:02.631>looking <00:19:02.865>for <00:19:03.098>a <00:19:03.331>FU <00:19:03.565>variable.

419
00:19:03.825 --> 00:19:06.225
<00:19:03.825>Again, <00:19:04.000>we <00:19:04.175>don't <00:19:04.350>have <00:19:04.525>one <00:19:04.700>in <00:19:04.875>the <00:19:05.050>current <00:19:05.225>scope.

420
00:19:06.245 --> 00:19:07.585
<00:19:06.245>We <00:19:06.417>don't <00:19:06.589>have <00:19:06.761>one <00:19:06.934>in <00:19:07.106>the <00:19:07.278>outer <00:19:07.451>scope.

421
00:19:07.725 --> 00:19:09.185
<00:19:07.725>We <00:19:08.053>eventually <00:19:08.381>find <00:19:08.710>the <00:19:09.039>one

422
00:19:09.185 --> 00:19:10.945
<00:19:09.185>that <00:19:09.385>we <00:19:09.585>created <00:19:09.784>in <00:19:09.985>the <00:19:10.185>global <00:19:10.385>scope <00:19:10.585>here.

423
00:19:11.165 --> 00:19:12.865
<00:19:11.165>And <00:19:11.445>so <00:19:11.725>we'll <00:19:12.004>console <00:19:12.284>log <00:19:12.565>Baz

424
00:19:13.655 --> 00:19:17.105
<00:19:13.655>leaving <00:19:13.795>our <00:19:13.935>function <00:19:14.075>we'll <00:19:14.215>now <00:19:14.355>go <00:19:14.495>looking <00:19:14.635>for <00:19:14.774>a <00:19:14.915>foo <00:19:15.055>variable

425
00:19:17.325 --> 00:19:21.185
<00:19:17.325>and <00:19:17.465>we <00:19:17.605>don't <00:19:17.745>find <00:19:17.885>one <00:19:18.025>anywhere <00:19:18.165>except <00:19:18.305>for <00:19:18.445>that <00:19:18.585>global <00:19:18.725>scope.

426
00:19:21.205 --> 00:19:25.785
<00:19:21.205>So <00:19:21.379>we'll <00:19:21.554>console <00:19:21.730>log <00:19:21.905>Bs <00:19:22.080>again, <00:19:22.254>bam, <00:19:22.429>B <00:19:22.605>Bs.

427
00:19:27.135 --> 00:19:31.795
<00:19:27.135>Wait <00:19:27.290>a <00:19:27.446>minute, <00:19:27.601>we <00:19:27.757>created <00:19:27.912>this <00:19:28.068>variable <00:19:28.223>inside <00:19:28.379>the <00:19:28.535>function

428
00:19:32.135 --> 00:19:34.275
<00:19:32.135>and <00:19:32.368>we <00:19:32.601>logged <00:19:32.835>it <00:19:33.068>outside <00:19:33.301>the <00:19:33.535>function

429
00:19:34.375 --> 00:19:35.515
<00:19:34.375>and <00:19:34.631>we <00:19:34.888>didn't <00:19:35.144>return <00:19:35.401>it.

430
00:19:36.055 --> 00:19:38.075
<00:19:36.055>How <00:19:36.405>did <00:19:36.755>that <00:19:37.105>happen? <00:19:37.455>Yeah,

431
00:19:38.075 --> 00:19:40.595
<00:19:38.075>because <00:19:38.355>we <00:19:38.635>didn't <00:19:38.915>declare <00:19:39.195>our <00:19:39.475>variable.

432
00:19:41.015 --> 00:19:42.915
<00:19:41.015>It <00:19:41.295>leaked <00:19:41.575>through <00:19:41.855>the <00:19:42.135>global <00:19:42.415>scope.

433
00:19:44.205 --> 00:19:46.305
<00:19:44.205>Now <00:19:44.405>what <00:19:44.605>if <00:19:44.804>this <00:19:45.004>variable <00:19:45.205>was <00:19:45.405>called <00:19:45.605>I

434
00:19:46.925 --> 00:19:48.825
<00:19:46.925>and <00:19:47.100>what <00:19:47.274>if <00:19:47.450>I <00:19:47.625>defined <00:19:47.800>one <00:19:47.975>in <00:19:48.149>this <00:19:48.325>way

435
00:19:48.825 --> 00:19:50.305
<00:19:48.825>and <00:19:49.047>you <00:19:49.269>defined <00:19:49.491>one <00:19:49.713>in <00:19:49.935>this <00:19:50.157>way,

436
00:19:50.535 --> 00:19:52.905
<00:19:50.535>then <00:19:50.690>we <00:19:50.846>would <00:19:51.001>both <00:19:51.157>be <00:19:51.312>using <00:19:51.468>the <00:19:51.623>same <00:19:51.779>I <00:19:51.935>variable

437
00:19:53.165 --> 00:19:54.425
<00:19:53.165>and <00:19:53.391>that <00:19:53.618>could <00:19:53.845>be <00:19:54.072>really <00:19:54.299>bad.

438
00:19:56.365 --> 00:19:58.825
<00:19:56.365>So <00:19:56.715>let's <00:19:57.065>define <00:19:57.415>this <00:19:57.765>variable.

439
00:19:59.265 --> 00:20:00.305
<00:19:59.265>That's <00:19:59.452>what <00:19:59.639>we <00:19:59.826>should <00:20:00.013>have <00:20:00.201>done.

440
00:20:00.645 --> 00:20:02.305
<00:20:00.645>And <00:20:00.878>now <00:20:01.111>let's <00:20:01.345>see <00:20:01.578>what <00:20:01.811>happens <00:20:02.045>here.

441
00:20:05.615 --> 00:20:07.165
<00:20:05.615>Let's <00:20:05.963>think <00:20:06.312>like <00:20:06.661>the <00:20:07.010>compiler

442
00:20:07.165 --> 00:20:08.365
<00:20:07.165>and <00:20:07.319>see <00:20:07.473>if <00:20:07.627>we <00:20:07.782>can <00:20:07.936>figure <00:20:08.090>it <00:20:08.245>out.

443
00:20:08.505 --> 00:20:10.365
<00:20:08.505>Our <00:20:08.738>first <00:20:08.971>task <00:20:09.205>is <00:20:09.438>to <00:20:09.671>allocate <00:20:09.905>variables.

444
00:20:10.545 --> 00:20:12.685
<00:20:10.545>We <00:20:10.720>have <00:20:10.895>an <00:20:11.070>outer <00:20:11.245>FU <00:20:11.420>and <00:20:11.595>an <00:20:11.770>inner <00:20:11.945>fu.

445
00:20:12.865 --> 00:20:14.485
<00:20:12.865>Now <00:20:13.065>that <00:20:13.265>we've <00:20:13.465>got <00:20:13.665>both <00:20:13.865>of <00:20:14.065>those <00:20:14.265>defined,

446
00:20:14.695 --> 00:20:15.845
<00:20:14.695>let's <00:20:15.212>start <00:20:15.730>executing.

447
00:20:16.175 --> 00:20:18.445
<00:20:16.175>We'll <00:20:16.375>define <00:20:16.575>our <00:20:16.774>function, <00:20:16.975>we'll <00:20:17.175>execute <00:20:17.375>our <00:20:17.575>function

448
00:20:18.545 --> 00:20:21.685
<00:20:18.545>and <00:20:18.672>our <00:20:18.799>first <00:20:18.926>task <00:20:19.054>is <00:20:19.181>to <00:20:19.308>set <00:20:19.435>this <00:20:19.563>outer <00:20:19.690>FU <00:20:19.817>to <00:20:19.945>baths.

449
00:20:22.545 --> 00:20:26.045
<00:20:22.545>Inside <00:20:22.672>the <00:20:22.799>curly <00:20:22.926>braces <00:20:23.054>we <00:20:23.181>have <00:20:23.308>this <00:20:23.435>one <00:20:23.563>that <00:20:23.690>is <00:20:23.817>also <00:20:23.945>scope

450
00:20:26.105 --> 00:20:27.365
<00:20:26.105>to <00:20:26.483>a <00:20:26.861>curly <00:20:27.239>brace.

451
00:20:27.625 --> 00:20:30.605
<00:20:27.625>So <00:20:27.780>we'll <00:20:27.936>set <00:20:28.091>this <00:20:28.247>variable <00:20:28.402>to <00:20:28.558>BAM <00:20:28.713>console <00:20:28.869>log <00:20:29.025>bam.

452
00:20:30.785 --> 00:20:33.205
<00:20:30.785>And <00:20:30.925>as <00:20:31.065>we <00:20:31.205>get <00:20:31.345>to <00:20:31.485>this <00:20:31.625>curly <00:20:31.765>brace <00:20:31.905>then <00:20:32.045>this <00:20:32.185>inner

453
00:20:33.405 --> 00:20:34.525
<00:20:33.405>FU <00:20:33.657>variable <00:20:33.909>goes <00:20:34.161>outta <00:20:34.413>scope.

454
00:20:35.105 --> 00:20:37.285
<00:20:35.105>Now <00:20:35.245>we'll <00:20:35.385>go <00:20:35.525>looking <00:20:35.665>for <00:20:35.805>a <00:20:35.945>foo <00:20:36.085>variable <00:20:36.225>In <00:20:36.365>our <00:20:36.505>current

455
00:20:37.285 --> 00:20:38.405
<00:20:37.285>scope <00:20:37.537>we <00:20:37.789>find <00:20:38.041>this <00:20:38.293>one.

456
00:20:38.585 --> 00:20:41.765
<00:20:38.585>So <00:20:38.725>we'll <00:20:38.865>console <00:20:39.005>log, <00:20:39.145>BAM <00:20:39.285>and <00:20:39.425>Baz <00:20:39.565>and <00:20:39.705>then <00:20:39.845>what <00:20:39.985>happens?

457
00:20:41.795 --> 00:20:45.365
<00:20:41.795>Here <00:20:41.950>we <00:20:42.106>go <00:20:42.261>looking <00:20:42.417>for <00:20:42.572>a <00:20:42.728>a <00:20:42.883>variable <00:20:43.039>called <00:20:43.195>fu.

458
00:20:45.665 --> 00:20:47.285
<00:20:45.665>We <00:20:45.945>commented <00:20:46.225>out <00:20:46.504>this <00:20:46.784>one <00:20:47.065>previously.

459
00:20:47.305 --> 00:20:50.605
<00:20:47.305>So <00:20:47.432>that <00:20:47.559>isn't <00:20:47.686>a <00:20:47.814>thing <00:20:47.941>We <00:20:48.068>could <00:20:48.195>keep <00:20:48.323>climbing <00:20:48.450>up <00:20:48.577>our <00:20:48.705>scopes

460
00:20:50.605 --> 00:20:53.365
<00:20:50.605>and <00:20:50.745>eventually <00:20:50.885>we <00:20:51.025>look <00:20:51.165>for <00:20:51.305>the <00:20:51.445>global <00:20:51.585>scope <00:20:51.725>FU <00:20:51.865>isn't <00:20:52.005>there

461
00:20:53.785 --> 00:20:56.325
<00:20:53.785>and <00:20:53.940>we <00:20:54.096>get <00:20:54.251>a <00:20:54.407>reference <00:20:54.562>error <00:20:54.718>FU <00:20:54.873>is <00:20:55.029>not <00:20:55.185>defined.

462
00:20:57.025 --> 00:20:59.285
<00:20:57.025>Yes, <00:20:57.180>we're <00:20:57.336>trying <00:20:57.491>to <00:20:57.647>read <00:20:57.802>the <00:20:57.958>value <00:20:58.113>of <00:20:58.269>a <00:20:58.425>variable

463
00:20:59.285 --> 00:21:01.165
<00:20:59.285>that <00:20:59.518>doesn't <00:20:59.751>exist <00:20:59.985>and <00:21:00.218>in <00:21:00.451>this <00:21:00.685>case

464
00:21:01.315 --> 00:21:05.125
<00:21:01.315>because <00:21:01.490>we <00:21:01.665>defined <00:21:01.840>it <00:21:02.015>here <00:21:02.190>then <00:21:02.365>it <00:21:02.540>didn't <00:21:02.715>leak

465
00:21:05.125 --> 00:21:06.405
<00:21:05.125>outside <00:21:05.509>of <00:21:05.893>our <00:21:06.277>function.

466
00:21:07.045 --> 00:21:10.455
<00:21:07.045>Perfect. <00:21:07.245>We've <00:21:07.445>solved <00:21:07.645>our <00:21:07.845>bug <00:21:08.045>by <00:21:08.245>defining <00:21:08.445>all

467
00:21:10.455 --> 00:21:13.135
<00:21:10.455>of <00:21:10.629>our <00:21:10.804>variables <00:21:10.980>so <00:21:11.155>that <00:21:11.330>they <00:21:11.504>don't <00:21:11.679>leak <00:21:11.855>out

468
00:21:13.135 --> 00:21:15.095
<00:21:13.135>of <00:21:13.335>our <00:21:13.535>current <00:21:13.735>scopes <00:21:13.935>and <00:21:14.135>cause <00:21:14.335>memory <00:21:14.535>leaks

469
00:21:15.195 --> 00:21:17.295
<00:21:15.195>or <00:21:15.895>cause <00:21:16.595>errors.

470
00:21:18.215 --> 00:21:19.595
<00:21:18.215>Now <00:21:18.370>in <00:21:18.525>this <00:21:18.680>case <00:21:18.836>we <00:21:18.991>do <00:21:19.146>get <00:21:19.301>an <00:21:19.457>error

471
00:21:19.655 --> 00:21:21.955
<00:21:19.655>but <00:21:19.830>yeah, <00:21:20.004>we <00:21:20.180>were <00:21:20.355>trying <00:21:20.530>to <00:21:20.705>read <00:21:20.879>a <00:21:21.055>variable

472
00:21:21.955 --> 00:21:24.795
<00:21:21.955>that <00:21:22.129>doesn't <00:21:22.304>exist <00:21:22.480>at <00:21:22.655>this <00:21:22.830>scope <00:21:23.004>and <00:21:23.179>that's <00:21:23.355>perfect.

473
00:21:24.975 --> 00:21:28.435
<00:21:24.975>We <00:21:25.130>would <00:21:25.286>rather <00:21:25.441>rather <00:21:25.597>have <00:21:25.752>this <00:21:25.908>than <00:21:26.063>variables <00:21:26.219>leaking <00:21:26.375>into

474
00:21:28.435 --> 00:21:30.715
<00:21:28.435>the <00:21:28.635>global <00:21:28.835>scope <00:21:29.034>that <00:21:29.235>might <00:21:29.435>conflict <00:21:29.635>with <00:21:29.835>other

475
00:21:31.665 --> 00:21:33.235
<00:21:31.665>scripts <00:21:32.014>running <00:21:32.365>in <00:21:32.715>our <00:21:33.065>environment.

476
00:21:36.925 --> 00:21:39.665
<00:21:36.925>So <00:21:37.125>now <00:21:37.325>let's <00:21:37.524>flip <00:21:37.725>from <00:21:37.925>let <00:21:38.125>to <00:21:38.325>constant

477
00:21:40.525 --> 00:21:41.655
<00:21:40.525>What <00:21:40.779>happens <00:21:41.033>in <00:21:41.287>this <00:21:41.542>case,

478
00:21:44.565 --> 00:21:46.555
<00:21:44.565>let's <00:21:44.740>think <00:21:44.915>like <00:21:45.090>the <00:21:45.265>compiler <00:21:45.440>and <00:21:45.615>figure <00:21:45.790>it <00:21:45.965>out.

479
00:21:46.735 --> 00:21:48.755
<00:21:46.735>Our <00:21:46.968>first <00:21:47.201>task <00:21:47.435>is <00:21:47.668>to <00:21:47.901>allocate <00:21:48.135>variables.

480
00:21:48.885 --> 00:21:51.315
<00:21:48.885>We've <00:21:49.040>got <00:21:49.196>an <00:21:49.351>outer <00:21:49.507>fu, <00:21:49.662>we've <00:21:49.818>got <00:21:49.973>an <00:21:50.129>inner <00:21:50.285>FU

481
00:21:51.495 --> 00:21:52.515
<00:21:51.495>and <00:21:51.678>now <00:21:51.862>we're <00:21:52.045>ready <00:21:52.229>to <00:21:52.413>go.

482
00:21:52.615 --> 00:21:56.475
<00:21:52.615>Second <00:21:52.755>pass <00:21:52.895>is <00:21:53.035>executing <00:21:53.175>we'll <00:21:53.315>set <00:21:53.455>our <00:21:53.595>outer <00:21:53.735>food <00:21:53.875>to <00:21:54.015>bar.

483
00:21:56.545 --> 00:21:58.595
<00:21:56.545>It's <00:21:56.720>a <00:21:56.895>constant <00:21:57.070>so <00:21:57.245>we <00:21:57.420>can't <00:21:57.595>change <00:21:57.770>that <00:21:57.945>anymore.

484
00:21:59.145 --> 00:22:01.555
<00:21:59.145>Then <00:21:59.320>we'll <00:21:59.495>define <00:21:59.670>our <00:21:59.845>function, <00:22:00.020>we'll <00:22:00.195>execute <00:22:00.370>our <00:22:00.545>function

485
00:22:01.735 --> 00:22:03.515
<00:22:01.735>and <00:22:01.909>now <00:22:02.084>we <00:22:02.260>go <00:22:02.435>looking <00:22:02.610>for <00:22:02.784>a <00:22:02.959>food <00:22:03.135>variable.

486
00:22:04.385 --> 00:22:07.115
<00:22:04.385>Well <00:22:04.540>this <00:22:04.696>one <00:22:04.851>is <00:22:05.007>inside <00:22:05.162>of <00:22:05.318>a <00:22:05.473>curly <00:22:05.629>brace <00:22:05.785>so

487
00:22:07.115 --> 00:22:08.275
<00:22:07.115>that <00:22:07.323>isn't <00:22:07.532>in <00:22:07.741>our <00:22:07.950>current <00:22:08.159>scope.

488
00:22:08.385 --> 00:22:09.715
<00:22:08.385>There's <00:22:08.624>none <00:22:08.863>in <00:22:09.103>our <00:22:09.342>current <00:22:09.581>scope.

489
00:22:09.775 --> 00:22:11.435
<00:22:09.775>So <00:22:09.950>we'll <00:22:10.125>find <00:22:10.300>this <00:22:10.475>one <00:22:10.650>in <00:22:10.825>our <00:22:11.000>outer <00:22:11.175>scope.

490
00:22:12.095 --> 00:22:14.195
<00:22:12.095>Now <00:22:12.250>we <00:22:12.406>go <00:22:12.561>to <00:22:12.717>set <00:22:12.872>it <00:22:13.028>from <00:22:13.183>bar <00:22:13.339>to <00:22:13.495>bas

491
00:22:14.335 --> 00:22:18.155
<00:22:14.335>and <00:22:14.510>we <00:22:14.685>can't, <00:22:14.860>it's <00:22:15.035>assigning <00:22:15.210>to <00:22:15.385>a <00:22:15.560>constant <00:22:15.735>variable

492
00:22:18.615 --> 00:22:19.995
<00:22:18.615>and <00:22:18.863>we <00:22:19.111>get <00:22:19.360>a <00:22:19.608>runtime <00:22:19.857>exception.

493
00:22:20.055 --> 00:22:22.795
<00:22:20.055>That's <00:22:20.210>great. <00:22:20.366>We've <00:22:20.521>told <00:22:20.677>it <00:22:20.832>that <00:22:20.988>this <00:22:21.143>is <00:22:21.299>constant <00:22:21.455>and

494
00:22:22.795 --> 00:22:23.955
<00:22:22.795>therefore <00:22:23.056>we <00:22:23.317>can't <00:22:23.578>change <00:22:23.839>it.

495
00:22:26.505 --> 00:22:27.765
<00:22:26.505>Now <00:22:26.788>what <00:22:27.072>if <00:22:27.355>we <00:22:27.639>were

496
00:22:28.765 --> 00:22:31.045
<00:22:28.765>piling <00:22:28.920>our <00:22:29.076>code <00:22:29.231>from <00:22:29.387>E <00:22:29.542>ES <00:22:29.698>six <00:22:29.853>to <00:22:30.009>ES <00:22:30.165>five?

497
00:22:32.015 --> 00:22:35.875
<00:22:32.015>Now <00:22:32.155>the <00:22:32.295>only <00:22:32.435>variable <00:22:32.575>declaration <00:22:32.715>in <00:22:32.855>ES <00:22:32.995>five <00:22:33.135>is <00:22:33.275>a <00:22:33.415>variable

498
00:22:36.175 --> 00:22:40.225
<00:22:36.175>and <00:22:36.350>we <00:22:36.524>know <00:22:36.700>that <00:22:36.875>VAR <00:22:37.050>is <00:22:37.225>um, <00:22:37.399>not <00:22:37.575>constant.

499
00:22:40.525 --> 00:22:43.705
<00:22:40.525>So <00:22:40.641>if <00:22:40.758>we <00:22:40.875>were <00:22:40.991>piling <00:22:41.108>this <00:22:41.225>from <00:22:41.341>E <00:22:41.458>ES <00:22:41.575>six <00:22:41.691>to <00:22:41.808>ES <00:22:41.925>five,

500
00:22:44.095 --> 00:22:46.385
<00:22:44.095>then <00:22:44.375>this <00:22:44.655>would <00:22:44.935>work <00:22:45.215>as <00:22:45.495>expected.

501
00:22:46.725 --> 00:22:49.665
<00:22:46.725>We <00:22:46.841>would <00:22:46.958>set <00:22:47.074>what <00:22:47.191>was <00:22:47.308>BARR <00:22:47.425>to <00:22:47.541>Baz <00:22:47.658>and <00:22:47.774>we <00:22:47.891>would <00:22:48.008>continue <00:22:48.125>on.

502
00:22:51.895 --> 00:22:55.975
<00:22:51.895>Hmm. <00:22:52.035>So <00:22:52.175>now <00:22:52.315>as <00:22:52.455>we <00:22:52.595>upgrade <00:22:52.735>our <00:22:52.875>transer <00:22:53.014>to <00:22:53.155>not <00:22:53.295>transpi

503
00:22:55.975 --> 00:22:58.775
<00:22:55.975>to <00:22:56.102>E <00:22:56.229>es <00:22:56.356>five <00:22:56.484>but <00:22:56.611>to <00:22:56.738>transp <00:22:56.865>to <00:22:56.993>E <00:22:57.120>ES <00:22:57.247>six <00:22:57.375>instead,

504
00:22:58.995 --> 00:23:00.055
<00:22:58.995>now <00:22:59.233>we <00:22:59.472>get <00:22:59.710>these <00:22:59.949>errors.

505
00:23:00.445 --> 00:23:04.775
<00:23:00.445>Wait <00:23:00.600>a <00:23:00.756>minute, <00:23:00.911>was <00:23:01.067>our <00:23:01.222>babble <00:23:01.378>config <00:23:01.533>to <00:23:01.689>blame <00:23:01.845>here?

506
00:23:05.395 --> 00:23:07.855
<00:23:05.395>No, <00:23:05.595>we <00:23:05.795>were <00:23:05.995>setting <00:23:06.195>to <00:23:06.395>a <00:23:06.595>constant <00:23:06.795>variable

507
00:23:08.235 --> 00:23:10.175
<00:23:08.235>and <00:23:08.409>we <00:23:08.584>just <00:23:08.760>didn't <00:23:08.935>see <00:23:09.110>that <00:23:09.284>at <00:23:09.459>the <00:23:09.635>time

508
00:23:10.175 --> 00:23:12.135
<00:23:10.175>because <00:23:10.408>Babel <00:23:10.641>had <00:23:10.875>masked <00:23:11.108>it <00:23:11.341>for <00:23:11.575>us.

509
00:23:13.285 --> 00:23:15.915
<00:23:13.285>Don't <00:23:13.460>blame <00:23:13.635>your <00:23:13.810>babel <00:23:13.985>config <00:23:14.160>when <00:23:14.335>you <00:23:14.510>get <00:23:14.685>assignment

510
00:23:15.975 --> 00:23:17.435
<00:23:15.975>to <00:23:16.303>a <00:23:16.631>constant <00:23:16.960>variable <00:23:17.289>errors.

511
00:23:17.625 --> 00:23:20.355
<00:23:17.625>Instead <00:23:17.780>go <00:23:17.936>find <00:23:18.091>those <00:23:18.247>constants <00:23:18.402>that <00:23:18.558>you <00:23:18.713>assigned <00:23:18.869>it <00:23:19.025>to

512
00:23:20.775 --> 00:23:23.755
<00:23:20.775>and <00:23:20.915>probably <00:23:21.055>we <00:23:21.195>need <00:23:21.335>to <00:23:21.475>change <00:23:21.615>this <00:23:21.755>from <00:23:21.895>constant <00:23:22.035>to <00:23:22.175>let

513
00:23:23.975 --> 00:23:25.795
<00:23:23.975>to <00:23:24.208>make <00:23:24.441>this <00:23:24.675>program <00:23:24.908>function <00:23:25.141>as <00:23:25.375>expected.

514
00:23:27.035 --> 00:23:31.115
<00:23:27.035>That's <00:23:27.210>perfect. <00:23:27.385>So <00:23:27.560>we <00:23:27.735>got <00:23:27.910>to <00:23:28.085>look <00:23:28.260>at <00:23:28.435>defining

515
00:23:31.335 --> 00:23:33.635
<00:23:31.335>and <00:23:31.568>not <00:23:31.801>defining <00:23:32.035>variables <00:23:32.268>in <00:23:32.501>various <00:23:32.735>scopes

516
00:23:33.775 --> 00:23:36.195
<00:23:33.775>and <00:23:33.950>how <00:23:34.125>that <00:23:34.300>impacts <00:23:34.475>the <00:23:34.650>way <00:23:34.825>our <00:23:35.000>programs <00:23:35.175>work.

517
00:23:37.305 --> 00:23:39.345
<00:23:37.305>Defining <00:23:37.480>variables <00:23:37.655>is <00:23:37.830>one <00:23:38.005>of <00:23:38.180>those <00:23:38.355>simpler <00:23:38.530>things, <00:23:38.705>but

518
00:23:39.345 --> 00:23:42.025
<00:23:39.345>because <00:23:39.500>we <00:23:39.656>got <00:23:39.811>to <00:23:39.967>look <00:23:40.122>behind <00:23:40.278>the <00:23:40.433>scenes <00:23:40.589>in <00:23:40.745>inside

519
00:23:42.025 --> 00:23:45.885
<00:23:42.025>of <00:23:42.165>JavaScript, <00:23:42.305>we <00:23:42.445>got <00:23:42.585>to <00:23:42.725>understand <00:23:42.865>more <00:23:43.005>of <00:23:43.145>why <00:23:43.285>it <00:23:43.425>is

520
00:23:46.065 --> 00:23:48.645
<00:23:46.065>so <00:23:46.205>weird <00:23:46.345>and <00:23:46.485>maybe <00:23:46.625>make <00:23:46.765>it <00:23:46.905>a <00:23:47.045>little <00:23:47.185>bit <00:23:47.325>less <00:23:47.465>weird.

521
00:23:49.395 --> 00:23:52.165
<00:23:49.395>Next, <00:23:49.570>let's <00:23:49.745>look <00:23:49.920>at <00:23:50.095>another <00:23:50.270>weird <00:23:50.445>thing <00:23:50.620>called <00:23:50.795>this.

522
00:23:53.345 --> 00:23:54.505
<00:23:53.345>I <00:23:53.693>love <00:23:54.041>this <00:23:54.389>definition

523
00:23:55.085 --> 00:23:57.265
<00:23:55.085>as <00:23:55.285>you <00:23:55.485>grab <00:23:55.685>these <00:23:55.885>slides <00:23:56.085>from <00:23:56.285>robert <00:23:56.485>rich.org,

524
00:23:57.265 --> 00:23:59.585
<00:23:57.265>click <00:23:57.420>on <00:23:57.576>these <00:23:57.731>blue <00:23:57.887>links <00:23:58.042>to <00:23:58.198>read <00:23:58.353>or <00:23:58.509>watch <00:23:58.665>more.

525
00:24:00.315 --> 00:24:01.525
<00:24:00.315>This <00:24:00.678>definition <00:24:01.041>is <00:24:01.404>great.

526
00:24:02.155 --> 00:24:04.565
<00:24:02.155>This <00:24:02.310>is <00:24:02.466>the <00:24:02.621>thing <00:24:02.777>to <00:24:02.932>the <00:24:03.088>left <00:24:03.243>of <00:24:03.399>the <00:24:03.555>dot.

527
00:24:05.525 --> 00:24:07.585
<00:24:05.525>Now <00:24:05.725>that <00:24:05.925>it's <00:24:06.125>kind <00:24:06.325>of <00:24:06.525>a <00:24:06.725>simple <00:24:06.925>definition

528
00:24:07.725 --> 00:24:10.145
<00:24:07.725>but <00:24:07.958>I <00:24:08.191>I <00:24:08.425>find <00:24:08.658>it <00:24:08.891>immensely <00:24:09.125>powerful.

529
00:24:10.795 --> 00:24:12.025
<00:24:10.795>Let's <00:24:10.979>take <00:24:11.164>a <00:24:11.348>look <00:24:11.533>at <00:24:11.717>this <00:24:11.902>code.

530
00:24:12.405 --> 00:24:17.295
<00:24:12.405>We <00:24:12.545>want <00:24:12.685>to <00:24:12.825>console <00:24:12.965>log <00:24:13.105>this.name. <00:24:13.245>What <00:24:13.385>happens <00:24:13.524>in <00:24:13.665>this <00:24:13.805>case?

531
00:24:19.925 --> 00:24:21.415
<00:24:19.925>Well <00:24:20.260>I <00:24:20.595>have <00:24:20.930>some <00:24:21.266>objects

532
00:24:21.475 --> 00:24:23.855
<00:24:21.475>and <00:24:21.630>I <00:24:21.786>could <00:24:21.941>have <00:24:22.097>defined <00:24:22.252>the <00:24:22.408>functions <00:24:22.563>in <00:24:22.719>line <00:24:22.875>here,

533
00:24:24.235 --> 00:24:26.615
<00:24:24.235>but <00:24:24.390>I <00:24:24.546>chose <00:24:24.701>to <00:24:24.857>define <00:24:25.012>them <00:24:25.168>in <00:24:25.323>this <00:24:25.479>external <00:24:25.635>function

534
00:24:26.615 --> 00:24:27.775
<00:24:26.615>and <00:24:26.823>just <00:24:27.032>link <00:24:27.241>them <00:24:27.450>into <00:24:27.659>place.

535
00:24:28.195 --> 00:24:32.575
<00:24:28.195>So <00:24:28.302>if <00:24:28.410>I <00:24:28.518>say <00:24:28.625>AB <00:24:28.733>one <00:24:28.841>speak <00:24:28.948>when <00:24:29.056>it, <00:24:29.164>when <00:24:29.271>it <00:24:29.379>gets <00:24:29.487>to <00:24:29.595>here,

536
00:24:32.885 --> 00:24:34.655
<00:24:32.885>what <00:24:33.040>is <00:24:33.196>the <00:24:33.351>thing <00:24:33.507>to <00:24:33.662>the <00:24:33.818>left, <00:24:33.973>to <00:24:34.129>the <00:24:34.285>dot?

537
00:24:35.045 --> 00:24:36.215
<00:24:35.045>Well <00:24:35.396>it's <00:24:35.747>AB <00:24:36.098>one.

538
00:24:36.515 --> 00:24:40.575
<00:24:36.515>So <00:24:36.631>in <00:24:36.748>this <00:24:36.865>case <00:24:36.981>I <00:24:37.098>get <00:24:37.215>doctor <00:24:37.331>OB <00:24:37.448>two <00:24:37.565>speak, <00:24:37.681>I <00:24:37.798>get <00:24:37.915>Skywalker

539
00:24:40.835 --> 00:24:43.815
<00:24:40.835>and <00:24:40.990>because <00:24:41.146>I <00:24:41.301>define <00:24:41.457>this <00:24:41.612>variable <00:24:41.768>in <00:24:41.923>the <00:24:42.079>global <00:24:42.235>scope,

540
00:24:44.365 --> 00:24:47.175
<00:24:44.365>then <00:24:44.540>when <00:24:44.715>I <00:24:44.890>say <00:24:45.065>speak <00:24:45.240>this, <00:24:45.415>what's <00:24:45.590>the <00:24:45.765>thing

541
00:24:47.175 --> 00:24:48.295
<00:24:47.175>to <00:24:47.376>the <00:24:47.578>left <00:24:47.779>of <00:24:47.981>the <00:24:48.183>dot?

542
00:24:48.295 --> 00:24:50.655
<00:24:48.295>Well <00:24:48.495>it's <00:24:48.695>global <00:24:48.895>in <00:24:49.095>this <00:24:49.295>case <00:24:49.495>probably <00:24:49.695>window.

543
00:24:51.115 --> 00:24:54.875
<00:24:51.115>And <00:24:51.315>so <00:24:51.515>I <00:24:51.715>get <00:24:51.915>Ninja, <00:24:52.115>ninja <00:24:52.315>Dr. <00:24:52.515>Skywalker.

544
00:24:55.635 --> 00:24:57.165
<00:24:55.635>Yeah <00:24:55.979>that <00:24:56.323>works <00:24:56.667>as <00:24:57.012>expected.

545
00:24:57.585 --> 00:24:59.885
<00:24:57.585>The <00:24:57.785>thing <00:24:57.985>to <00:24:58.185>the <00:24:58.385>left <00:24:58.585>of <00:24:58.785>the.is <00:24:58.985>this.

546
00:25:01.375 --> 00:25:03.145
<00:25:01.375>Well <00:25:01.608>what <00:25:01.841>if <00:25:02.075>we <00:25:02.308>take <00:25:02.541>that <00:25:02.775>function

547
00:25:03.365 --> 00:25:04.705
<00:25:03.365>and <00:25:03.566>we <00:25:03.767>assign <00:25:03.968>it <00:25:04.168>to <00:25:04.370>a <00:25:04.571>variable?

548
00:25:05.325 --> 00:25:07.905
<00:25:05.325>Now <00:25:05.525>variables <00:25:05.725>in <00:25:05.925>JavaScript <00:25:06.125>are <00:25:06.325>first <00:25:06.525>class <00:25:06.725>citizens.

549
00:25:08.005 --> 00:25:10.145
<00:25:08.005>So <00:25:08.285>this <00:25:08.565>isn't <00:25:08.845>an <00:25:09.125>unusual <00:25:09.405>thing.

550
00:25:10.245 --> 00:25:13.425
<00:25:10.245>We <00:25:10.372>just <00:25:10.499>have <00:25:10.626>this <00:25:10.754>function <00:25:10.881>that <00:25:11.008>we <00:25:11.135>have <00:25:11.263>in <00:25:11.390>an <00:25:11.517>extra <00:25:11.645>spot.

551
00:25:14.005 --> 00:25:18.095
<00:25:14.005>What <00:25:14.471>happens <00:25:14.938>here? <00:25:15.405>Well

552
00:25:18.635 --> 00:25:19.775
<00:25:18.635>what's <00:25:18.840>the <00:25:19.045>thing <00:25:19.250>to <00:25:19.455>the <00:25:19.661>left

553
00:25:19.775 --> 00:25:21.415
<00:25:19.775>of <00:25:19.975>the <00:25:20.175>dot <00:25:20.375>when <00:25:20.575>we <00:25:20.775>call <00:25:20.975>OB <00:25:21.175>speak?

554
00:25:23.315 --> 00:25:24.725
<00:25:23.315>Well <00:25:23.632>it's <00:25:23.949>the <00:25:24.266>global <00:25:24.583>object.

555
00:25:24.905 --> 00:25:27.965
<00:25:24.905>So <00:25:25.060>when <00:25:25.216>we <00:25:25.371>get <00:25:25.527>in <00:25:25.682>here, <00:25:25.838>we <00:25:25.993>cons <00:25:26.149>log <00:25:26.305>this.name

556
00:25:28.345 --> 00:25:29.645
<00:25:28.345>and <00:25:28.930>that's <00:25:29.514>undefined.

557
00:25:30.185 --> 00:25:31.445
<00:25:30.185>Now <00:25:30.411>that <00:25:30.638>is <00:25:30.865>making <00:25:31.092>an <00:25:31.319>assumption

558
00:25:31.445 --> 00:25:33.045
<00:25:31.445>that <00:25:31.794>something <00:25:32.145>defined <00:25:32.495>a <00:25:32.845>name.

559
00:25:33.545 --> 00:25:35.885
<00:25:33.545>So <00:25:33.720>maybe <00:25:33.895>we <00:25:34.070>might <00:25:34.245>get <00:25:34.420>a <00:25:34.595>type <00:25:34.770>error <00:25:34.945>saying

560
00:25:35.885 --> 00:25:37.005
<00:25:35.885>that <00:25:36.221>variable <00:25:36.557>doesn't <00:25:36.893>exist

561
00:25:37.265 --> 00:25:38.805
<00:25:37.265>but <00:25:37.496>we'll <00:25:37.727>just <00:25:37.958>say <00:25:38.189>undefined <00:25:38.420>for <00:25:38.651>now.

562
00:25:39.345 --> 00:25:41.445
<00:25:39.345>AB <00:25:39.545>one <00:25:39.745>does <00:25:39.945>speak <00:25:40.145>though <00:25:40.345>works <00:25:40.545>just <00:25:40.745>fine.

563
00:25:42.065 --> 00:25:44.205
<00:25:42.065>The <00:25:42.240>thing <00:25:42.415>to <00:25:42.590>the <00:25:42.765>left <00:25:42.940>of <00:25:43.115>the.is <00:25:43.290>AB <00:25:43.465>one.

564
00:25:44.505 --> 00:25:45.725
<00:25:44.505>And <00:25:44.779>so <00:25:45.054>we <00:25:45.328>get <00:25:45.602>doctor,

565
00:25:48.625 --> 00:25:50.685
<00:25:48.625>so <00:25:48.765>let's <00:25:48.905>take <00:25:49.045>this <00:25:49.185>knowledge <00:25:49.325>about <00:25:49.465>the <00:25:49.605>thing <00:25:49.745>to <00:25:49.885>the <00:25:50.025>left

566
00:25:50.685 --> 00:25:52.885
<00:25:50.685>of <00:25:50.825>the <00:25:50.965>dot <00:25:51.105>and <00:25:51.245>use <00:25:51.385>it <00:25:51.524>for <00:25:51.665>our <00:25:51.804>click <00:25:51.945>event <00:25:52.085>handler.

567
00:25:53.095 --> 00:25:55.085
<00:25:53.095>We're <00:25:53.328>gonna <00:25:53.561>say <00:25:53.795>button <00:25:54.028>at <00:25:54.261>event <00:25:54.495>listener.

568
00:25:55.295 --> 00:25:56.845
<00:25:55.295>We're <00:25:55.574>gonna <00:25:55.853>call <00:25:56.132>that <00:25:56.411>speak <00:25:56.690>function.

569
00:25:57.025 --> 00:25:59.445
<00:25:57.025>And <00:25:57.200>so <00:25:57.375>now <00:25:57.550>when <00:25:57.725>I <00:25:57.900>call <00:25:58.075>this <00:25:58.250>speak <00:25:58.425>function,

570
00:25:59.745 --> 00:26:02.645
<00:25:59.745>now <00:25:59.919>I'm <00:26:00.094>gonna <00:26:00.270>console <00:26:00.445>log <00:26:00.620>this.id <00:26:00.794>instead <00:26:00.969>of <00:26:01.145>this.name

571
00:26:02.645 --> 00:26:05.285
<00:26:02.645>because <00:26:02.878>I <00:26:03.111>got <00:26:03.345>my <00:26:03.578>element <00:26:03.811>by <00:26:04.045>id.

572
00:26:05.525 --> 00:26:08.395
<00:26:05.525>I <00:26:05.758>know <00:26:05.991>that <00:26:06.225>this.id <00:26:06.458>is <00:26:06.691>the <00:26:06.925>button.

573
00:26:09.295 --> 00:26:12.195
<00:26:09.295>The <00:26:09.435>thing <00:26:09.575>to <00:26:09.715>the <00:26:09.855>left <00:26:09.995>of <00:26:10.135>the.is <00:26:10.275>this <00:26:10.415>button <00:26:10.555>right <00:26:10.695>here.

574
00:26:12.535 --> 00:26:13.955
<00:26:12.535>That's <00:26:12.790>the <00:26:13.046>thing <00:26:13.301>that <00:26:13.557>was <00:26:13.812>clicked.

575
00:26:14.225 --> 00:26:17.715
<00:26:14.225>Therefore <00:26:14.425>that's <00:26:14.625>the <00:26:14.824>this <00:26:15.024>when <00:26:15.225>this <00:26:15.425>function <00:26:15.625>is

576
00:26:17.715 --> 00:26:19.135
<00:26:17.715>called <00:26:18.993>great.

577
00:26:20.665 --> 00:26:22.205
<00:26:20.665>Now <00:26:20.863>I <00:26:21.061>want <00:26:21.259>to <00:26:21.456>do <00:26:21.655>a <00:26:21.852>similar <00:26:22.051>thing,

578
00:26:22.385 --> 00:26:26.485
<00:26:22.385>but <00:26:22.525>in <00:26:22.665>this <00:26:22.805>case <00:26:22.945>I <00:26:23.085>want <00:26:23.225>to <00:26:23.365>um, <00:26:23.504>console <00:26:23.645>log <00:26:23.785>this.name

579
00:26:26.855 --> 00:26:28.245
<00:26:26.855>after <00:26:27.272>a <00:26:27.688>hundred <00:26:28.106>milliseconds.

580
00:26:28.245 --> 00:26:32.355
<00:26:28.245>So <00:26:28.372>I'm <00:26:28.499>gonna <00:26:28.626>do <00:26:28.754>a <00:26:28.881>set <00:26:29.008>timeout <00:26:29.135>there. <00:26:29.263>So <00:26:29.390>what <00:26:29.517>happens <00:26:29.645>here?

581
00:26:33.935 --> 00:26:35.745
<00:26:33.935>Well <00:26:34.215>our <00:26:34.495>first <00:26:34.774>pass, <00:26:35.054>we're <00:26:35.335>going

582
00:26:35.765 --> 00:26:38.785
<00:26:35.765>to <00:26:35.965>call <00:26:36.165>speak <00:26:36.365>using <00:26:36.565>the <00:26:36.765>global <00:26:36.965>object <00:26:37.165>here.

583
00:26:39.365 --> 00:26:42.865
<00:26:39.365>Um, <00:26:39.492>when <00:26:39.619>we <00:26:39.746>do <00:26:39.874>a <00:26:40.001>set <00:26:40.128>timeout, <00:26:40.255>this <00:26:40.383>creates <00:26:40.510>a <00:26:40.637>new <00:26:40.765>scope.

584
00:26:42.995 --> 00:26:45.165
<00:26:42.995>When <00:26:43.228>this <00:26:43.461>runs <00:26:43.695>in <00:26:43.928>a <00:26:44.161>hundred <00:26:44.395>milliseconds.

585
00:26:45.425 --> 00:26:48.485
<00:26:45.425>So <00:26:45.565>this.name, <00:26:45.705>it's <00:26:45.845>gonna <00:26:45.985>go <00:26:46.125>look <00:26:46.264>in <00:26:46.405>the <00:26:46.544>global <00:26:46.685>object <00:26:46.825>here

586
00:26:48.785 --> 00:26:52.275
<00:26:48.785>and <00:26:48.985>we <00:26:49.185>get <00:26:49.385>ninja <00:26:49.585>that <00:26:49.785>worked <00:26:49.985>kind <00:26:50.185>of

587
00:26:52.885 --> 00:26:54.355
<00:26:52.885>let's <00:26:53.149>do <00:26:53.414>obs <00:26:53.678>one <00:26:53.943>do <00:26:54.208>speak.

588
00:26:55.135 --> 00:26:57.475
<00:26:55.135>Now <00:26:55.290>when <00:26:55.446>we <00:26:55.601>set <00:26:55.757>time <00:26:55.912>out <00:26:56.068>for <00:26:56.223>a <00:26:56.379>hundred <00:26:56.535>milliseconds,

589
00:26:57.475 --> 00:27:00.955
<00:26:57.475>we <00:26:57.602>create <00:26:57.729>a <00:26:57.856>new <00:26:57.984>scope <00:26:58.111>and <00:26:58.238>this.name <00:26:58.365>is <00:26:58.493>now <00:26:58.620>the <00:26:58.747>global <00:26:58.875>object

590
00:27:01.655 --> 00:27:02.955
<00:27:01.655>and <00:27:01.947>we <00:27:02.240>also <00:27:02.532>get <00:27:02.824>ninja.

591
00:27:04.035 --> 00:27:06.715
<00:27:04.035>Hmm, <00:27:04.268>that's <00:27:04.501>not <00:27:04.735>exactly <00:27:04.968>what <00:27:05.201>we <00:27:05.435>expected.

592
00:27:09.285 --> 00:27:11.475
<00:27:09.285>Let's <00:27:09.518>see <00:27:09.751>if <00:27:09.985>we <00:27:10.218>can <00:27:10.451>control <00:27:10.685>this.

593
00:27:12.595 --> 00:27:15.495
<00:27:12.595>Now <00:27:12.750>we <00:27:12.906>can <00:27:13.061>do, <00:27:13.217>we <00:27:13.372>can <00:27:13.528>control <00:27:13.683>this <00:27:13.839>with <00:27:13.995>call.

594
00:27:16.635 --> 00:27:19.615
<00:27:16.635>Here's <00:27:16.790>the <00:27:16.946>syntax <00:27:17.101>where <00:27:17.257>we <00:27:17.412>say <00:27:17.568>OB <00:27:17.723>one <00:27:17.879>do <00:27:18.035>speak.call

595
00:27:19.715 --> 00:27:22.215
<00:27:19.715>and <00:27:19.870>we <00:27:20.026>pass <00:27:20.181>in <00:27:20.337>what <00:27:20.492>we <00:27:20.648>want <00:27:20.803>this <00:27:20.959>to <00:27:21.115>be.

596
00:27:22.555 --> 00:27:24.135
<00:27:22.555>Now <00:27:22.788>we're <00:27:23.021>kind <00:27:23.255>of <00:27:23.488>creating <00:27:23.721>an <00:27:23.955>envelope

597
00:27:24.155 --> 00:27:27.015
<00:27:24.155>and <00:27:24.310>we're <00:27:24.466>saying <00:27:24.621>I'm <00:27:24.777>gonna <00:27:24.932>pack <00:27:25.088>this <00:27:25.243>function <00:27:25.399>into <00:27:25.555>place

598
00:27:27.495 --> 00:27:28.775
<00:27:27.495>together <00:27:27.783>with <00:27:28.071>the <00:27:28.359>this <00:27:28.647>and

599
00:27:28.775 --> 00:27:30.015
<00:27:28.775>therefore <00:27:29.054>when <00:27:29.333>you <00:27:29.612>call <00:27:29.891>it

600
00:27:30.275 --> 00:27:32.575
<00:27:30.275>that's <00:27:30.508>the <00:27:30.741>this <00:27:30.975>that <00:27:31.208>will <00:27:31.441>happen <00:27:31.675>here.

601
00:27:33.395 --> 00:27:34.775
<00:27:33.395>So <00:27:33.809>what <00:27:34.223>happens <00:27:34.637>here?

602
00:27:35.715 --> 00:27:39.725
<00:27:35.715>Well <00:27:35.855>we <00:27:35.995>saw <00:27:36.135>AB <00:27:36.274>one <00:27:36.415>speak <00:27:36.554>that <00:27:36.695>correctly <00:27:36.834>does <00:27:36.975>uh, <00:27:37.115>doctor,

603
00:27:40.105 --> 00:27:43.125
<00:27:40.105>but <00:27:40.280>when <00:27:40.455>we <00:27:40.630>say <00:27:40.805>OB <00:27:40.980>one <00:27:41.155>speak.call <00:27:41.330>OB <00:27:41.505>two,

604
00:27:43.575 --> 00:27:46.285
<00:27:43.575>we've <00:27:43.775>passed <00:27:43.975>in <00:27:44.175>OB <00:27:44.375>two <00:27:44.575>as <00:27:44.775>the <00:27:44.975>this

605
00:27:46.665 --> 00:27:48.525
<00:27:46.665>and <00:27:46.898>so <00:27:47.131>we <00:27:47.365>will <00:27:47.598>correctly <00:27:47.831>get <00:27:48.065>Skywalker.

606
00:27:49.105 --> 00:27:51.565
<00:27:49.105>Now <00:27:49.232>I <00:27:49.359>could <00:27:49.486>have <00:27:49.614>defined <00:27:49.741>the <00:27:49.868>function <00:27:49.995>here <00:27:50.123>in <00:27:50.250>this <00:27:50.377>case <00:27:50.505>I

607
00:27:51.565 --> 00:27:54.045
<00:27:51.565>chose <00:27:51.720>to <00:27:51.876>admit <00:27:52.031>it, <00:27:52.187>but <00:27:52.342>basically <00:27:52.498>we're <00:27:52.653>just <00:27:52.809>calling <00:27:52.965>the

608
00:27:54.045 --> 00:27:56.485
<00:27:54.045>other <00:27:54.278>objects <00:27:54.511>thing <00:27:54.745>overriding <00:27:54.978>what <00:27:55.211>this <00:27:55.445>is.

609
00:27:57.185 --> 00:27:59.485
<00:27:57.185>So <00:27:57.418>we <00:27:57.651>get <00:27:57.885>the <00:27:58.118>correct <00:27:58.351>answer. <00:27:58.585>Great.

610
00:28:00.545 --> 00:28:02.205
<00:28:00.545>Now <00:28:00.778>let's <00:28:01.011>come <00:28:01.245>back <00:28:01.478>to <00:28:01.711>our <00:28:01.945>example

611
00:28:02.625 --> 00:28:05.205
<00:28:02.625>to <00:28:02.825>see <00:28:03.025>if <00:28:03.225>we <00:28:03.425>can <00:28:03.625>do <00:28:03.825>call <00:28:04.025>this

612
00:28:05.945 --> 00:28:10.605
<00:28:05.945>to <00:28:06.100>correctly <00:28:06.256>identify <00:28:06.411>the <00:28:06.567>this <00:28:06.722>as <00:28:06.878>we <00:28:07.033>execute <00:28:07.189>this <00:28:07.345>function.

613
00:28:12.255 --> 00:28:13.995
<00:28:12.255>Now <00:28:12.535>let's <00:28:12.815>do <00:28:13.095>AB <00:28:13.375>one <00:28:13.655>speak.

614
00:28:14.655 --> 00:28:15.675
<00:28:14.655>What's <00:28:15.114>the <00:28:15.572>this

615
00:28:15.675 --> 00:28:20.155
<00:28:15.675>as <00:28:15.830>we <00:28:15.986>enter <00:28:16.141>here <00:28:16.297>it <00:28:16.452>is <00:28:16.608>AB <00:28:16.763>one <00:28:16.919>soap <00:28:17.075>call.

616
00:28:20.415 --> 00:28:22.515
<00:28:20.415>Here's <00:28:20.615>the <00:28:20.815>OBS <00:28:21.014>one <00:28:21.215>that <00:28:21.415>we <00:28:21.615>passed <00:28:21.815>in

617
00:28:22.775 --> 00:28:26.275
<00:28:22.775>and <00:28:22.930>now <00:28:23.086>it <00:28:23.241>will <00:28:23.397>run <00:28:23.552>this <00:28:23.708>function <00:28:23.863>correctly <00:28:24.019>identifying <00:28:24.175>this

618
00:28:26.275 --> 00:28:27.915
<00:28:26.275>as <00:28:26.508>OB <00:28:26.741>one <00:28:26.975>and <00:28:27.208>we'll <00:28:27.441>get <00:28:27.675>doctor,

619
00:28:28.415 --> 00:28:30.555
<00:28:28.415>but <00:28:28.648>this <00:28:28.881>is <00:28:29.115>going <00:28:29.348>to <00:28:29.581>execute <00:28:29.815>immediately

620
00:28:31.025 --> 00:28:33.915
<00:28:31.025>what <00:28:31.180>returns <00:28:31.336>from <00:28:31.491>this <00:28:31.647>is <00:28:31.802>the <00:28:31.958>results <00:28:32.113>of <00:28:32.269>this <00:28:32.425>function

621
00:28:33.915 --> 00:28:36.995
<00:28:33.915>and <00:28:34.090>in <00:28:34.264>a <00:28:34.440>hundred <00:28:34.615>milliseconds <00:28:34.790>then <00:28:34.965>undefined <00:28:35.139>we'll <00:28:35.315>get

622
00:28:37.155 --> 00:28:40.695
<00:28:37.155>called, <00:28:37.388>okay, <00:28:37.621>we <00:28:37.855>got <00:28:38.088>the <00:28:38.321>right <00:28:38.555>answer

623
00:28:41.235 --> 00:28:43.135
<00:28:41.235>but <00:28:41.468>it <00:28:41.701>didn't <00:28:41.935>wait <00:28:42.168>a <00:28:42.401>hundred <00:28:42.635>milliseconds,

624
00:28:43.135 --> 00:28:44.455
<00:28:43.135>it <00:28:43.531>executed <00:28:43.927>right <00:28:44.322>now.

625
00:28:45.635 --> 00:28:49.675
<00:28:45.635>Hmm, <00:28:45.790>let's <00:28:45.946>keep <00:28:46.101>thinking, <00:28:46.257>let's <00:28:46.412>take <00:28:46.568>a <00:28:46.723>look <00:28:46.879>at <00:28:47.035>bind.

626
00:28:49.935 --> 00:28:50.955
<00:28:49.935>Now <00:28:50.241>bind <00:28:50.547>is <00:28:50.852>great.

627
00:28:51.185 --> 00:28:52.635
<00:28:51.185>This <00:28:51.402>is <00:28:51.620>not <00:28:51.837>the <00:28:52.055>syntax <00:28:52.272>of <00:28:52.490>bind

628
00:28:52.635 --> 00:28:54.275
<00:28:52.635>but <00:28:52.775>this <00:28:52.915>is <00:28:53.055>kind <00:28:53.195>of <00:28:53.335>how <00:28:53.475>we <00:28:53.615>might <00:28:53.754>think <00:28:53.895>through <00:28:54.035>it.

629
00:28:54.735 --> 00:28:56.075
<00:28:54.735>We <00:28:54.976>can <00:28:55.217>pass <00:28:55.458>in <00:28:55.699>our <00:28:55.941>function,

630
00:28:56.335 --> 00:28:58.155
<00:28:56.335>we <00:28:56.490>can <00:28:56.646>pass <00:28:56.801>in <00:28:56.957>what <00:28:57.112>we <00:28:57.268>want <00:28:57.423>this <00:28:57.579>to <00:28:57.735>be.

631
00:28:58.155 --> 00:28:59.555
<00:28:58.155>In <00:28:58.335>this <00:28:58.515>case <00:28:58.695>I'm <00:28:58.875>gonna <00:28:59.055>call <00:28:59.235>it <00:28:59.415>that.

632
00:29:00.135 --> 00:29:02.755
<00:29:00.135>And <00:29:00.275>then <00:29:00.415>we're <00:29:00.555>gonna <00:29:00.695>return <00:29:00.835>a <00:29:00.975>new <00:29:01.115>function <00:29:01.254>that <00:29:01.395>is <00:29:01.535>going

633
00:29:02.755 --> 00:29:05.835
<00:29:02.755>to <00:29:02.895>close <00:29:03.035>over <00:29:03.175>that <00:29:03.315>variable <00:29:03.455>to <00:29:03.595>keep <00:29:03.735>a <00:29:03.875>reference <00:29:04.015>to <00:29:04.155>it.

634
00:29:06.655 --> 00:29:08.795
<00:29:06.655>Now <00:29:06.888>we <00:29:07.121>have <00:29:07.355>this <00:29:07.588>new <00:29:07.821>function <00:29:08.055>and

635
00:29:08.995 --> 00:29:10.435
<00:29:08.995>whenever <00:29:09.157>we <00:29:09.319>call <00:29:09.481>it, <00:29:09.643>it <00:29:09.804>will <00:29:09.966>call <00:29:10.129>our <00:29:10.291>old

636
00:29:10.715 --> 00:29:11.955
<00:29:10.715>function <00:29:11.273>overriding <00:29:11.831>this.

637
00:29:13.375 --> 00:29:15.755
<00:29:13.375>So <00:29:13.550>let's <00:29:13.725>call <00:29:13.900>it <00:29:14.075>with <00:29:14.250>speak <00:29:14.425>and <00:29:14.600>S <00:29:14.775>two

638
00:29:16.095 --> 00:29:17.955
<00:29:16.095>and <00:29:16.295>then <00:29:16.495>when <00:29:16.695>we <00:29:16.895>call <00:29:17.095>OB <00:29:17.295>two <00:29:17.495>speak,

639
00:29:18.225 --> 00:29:21.755
<00:29:18.225>then <00:29:18.425>what's <00:29:18.625>the <00:29:18.824>this <00:29:19.024>here <00:29:19.225>is <00:29:19.425>OB <00:29:19.625>two.

640
00:29:21.825 --> 00:29:25.675
<00:29:21.825>Perfect. <00:29:22.025>Now <00:29:22.225>let's <00:29:22.425>use <00:29:22.625>the <00:29:22.825>real <00:29:23.025>bind <00:29:23.225>syntax

641
00:29:25.975 --> 00:29:28.835
<00:29:25.975>and <00:29:26.149>we <00:29:26.324>call <00:29:26.500>OB <00:29:26.675>one <00:29:26.850>speak <00:29:27.024>bind <00:29:27.199>OB <00:29:27.375>two,

642
00:29:29.095 --> 00:29:30.475
<00:29:29.095>but <00:29:29.302>it's <00:29:29.509>not <00:29:29.716>calling <00:29:29.923>it <00:29:30.129>right <00:29:30.337>away,

643
00:29:30.475 --> 00:29:33.155
<00:29:30.475>it's <00:29:30.675>returning <00:29:30.875>a <00:29:31.074>new <00:29:31.274>function <00:29:31.475>with <00:29:31.675>that <00:29:31.875>this

644
00:29:33.455 --> 00:29:34.795
<00:29:33.455>inside <00:29:34.058>that <00:29:34.661>envelope.

645
00:29:35.785 --> 00:29:36.965
<00:29:35.785>So <00:29:36.139>what <00:29:36.493>happens <00:29:36.847>here?

646
00:29:39.365 --> 00:29:42.285
<00:29:39.365>Well <00:29:39.520>when <00:29:39.676>I <00:29:39.831>call <00:29:39.987>AB <00:29:40.142>one <00:29:40.298>speak, <00:29:40.453>that <00:29:40.609>works <00:29:40.765>exactly

647
00:29:42.385 --> 00:29:44.805
<00:29:42.385>as <00:29:42.560>we <00:29:42.735>expect <00:29:42.910>when <00:29:43.085>I <00:29:43.260>call <00:29:43.435>OB <00:29:43.610>two <00:29:43.785>speak,

648
00:29:45.145 --> 00:29:48.125
<00:29:45.145>it <00:29:45.285>has <00:29:45.425>the <00:29:45.565>this <00:29:45.705>already <00:29:45.845>bound <00:29:45.985>into <00:29:46.125>it <00:29:46.264>from <00:29:46.405>OBS <00:29:46.545>two

649
00:29:48.425 --> 00:29:50.205
<00:29:48.425>and <00:29:48.705>so <00:29:48.985>we <00:29:49.264>correctly <00:29:49.544>get <00:29:49.825>Skywalker.

650
00:29:52.865 --> 00:29:56.285
<00:29:52.865>So <00:29:52.992>now <00:29:53.119>what <00:29:53.246>if <00:29:53.374>we <00:29:53.501>do <00:29:53.628>something <00:29:53.755>like <00:29:53.883>this <00:29:54.010>OBS <00:29:54.137>two <00:29:54.265>speak,

651
00:29:56.605 --> 00:29:59.165
<00:29:56.605>bind <00:29:56.732>obs <00:29:56.859>two, <00:29:56.986>you <00:29:57.114>might <00:29:57.241>see <00:29:57.368>that <00:29:57.495>in <00:29:57.623>your <00:29:57.750>code <00:29:57.877>in <00:29:58.005>places.

652
00:29:59.545 --> 00:30:01.845
<00:29:59.545>That's <00:29:59.825>saying <00:30:00.105>I <00:30:00.385>very <00:30:00.665>specifically <00:30:00.945>want

653
00:30:01.845 --> 00:30:04.885
<00:30:01.845>to <00:30:02.020>override <00:30:02.195>the <00:30:02.370>this <00:30:02.545>in <00:30:02.720>all <00:30:02.895>of <00:30:03.070>these <00:30:03.245>functions.

654
00:30:05.185 --> 00:30:09.125
<00:30:05.185>So <00:30:05.301>now <00:30:05.418>I <00:30:05.534>don't <00:30:05.651>have <00:30:05.768>to <00:30:05.885>worry <00:30:06.001>about <00:30:06.118>was <00:30:06.235>it <00:30:06.351>an <00:30:06.468>external <00:30:06.585>button

655
00:30:09.125 --> 00:30:11.285
<00:30:09.125>that <00:30:09.325>clicked <00:30:09.525>it <00:30:09.725>that <00:30:09.925>called <00:30:10.125>into <00:30:10.325>my <00:30:10.525>object.

656
00:30:11.685 --> 00:30:13.965
<00:30:11.685>I <00:30:11.812>just <00:30:11.939>want <00:30:12.066>to <00:30:12.194>make <00:30:12.321>sure <00:30:12.448>that <00:30:12.575>my <00:30:12.703>object <00:30:12.830>has <00:30:12.957>the <00:30:13.085>correct

657
00:30:14.075 --> 00:30:15.245
<00:30:14.075>this <00:30:14.285>in <00:30:14.496>all <00:30:14.706>of <00:30:14.917>the <00:30:15.128>places.

658
00:30:17.385 --> 00:30:18.925
<00:30:17.385>So <00:30:17.662>let's <00:30:17.939>use <00:30:18.216>dot <00:30:18.493>bind <00:30:18.771>here

659
00:30:18.945 --> 00:30:21.165
<00:30:18.945>and <00:30:19.145>see <00:30:19.345>if <00:30:19.544>we <00:30:19.745>can <00:30:19.945>overcome <00:30:20.145>our <00:30:20.345>concern.

660
00:30:21.705 --> 00:30:23.725
<00:30:21.705>Now <00:30:21.905>dot <00:30:22.105>bind <00:30:22.304>will <00:30:22.504>return <00:30:22.705>a <00:30:22.905>new <00:30:23.105>function.

661
00:30:23.945 --> 00:30:27.885
<00:30:23.945>So <00:30:24.061>when <00:30:24.178>we <00:30:24.294>call <00:30:24.411>OB <00:30:24.528>one <00:30:24.645>do <00:30:24.761>speak <00:30:24.878>OB <00:30:24.995>one <00:30:25.111>is <00:30:25.228>the <00:30:25.345>this,

662
00:30:27.905 --> 00:30:32.445
<00:30:27.905>in <00:30:28.032>this <00:30:28.159>case <00:30:28.286>we'll <00:30:28.414>call <00:30:28.541>do <00:30:28.668>bind <00:30:28.795>binding <00:30:28.923>OB <00:30:29.050>one <00:30:29.177>into <00:30:29.305>plays.

663
00:30:32.865 --> 00:30:35.205
<00:30:32.865>So <00:30:33.065>now <00:30:33.265>we've <00:30:33.465>put <00:30:33.665>that <00:30:33.865>uh, <00:30:34.065>function <00:30:34.265>together

664
00:30:35.205 --> 00:30:37.245
<00:30:35.205>with <00:30:35.485>OB <00:30:35.764>one <00:30:36.044>in <00:30:36.324>this <00:30:36.605>envelope

665
00:30:37.625 --> 00:30:40.805
<00:30:37.625>and <00:30:37.780>in <00:30:37.936>a <00:30:38.091>hundred <00:30:38.247>milliseconds <00:30:38.402>we <00:30:38.558>get <00:30:38.713>OG <00:30:38.869>one <00:30:39.025>name

666
00:30:41.105 --> 00:30:45.815
<00:30:41.105>and <00:30:41.245>yes <00:30:41.385>we <00:30:41.525>get <00:30:41.665>our <00:30:41.805>correct <00:30:41.945>answer, <00:30:42.085>the <00:30:42.225>doctor <00:30:42.365>very <00:30:42.505>nice.

667
00:30:46.875 --> 00:30:48.455
<00:30:46.875>So <00:30:47.075>we <00:30:47.275>were <00:30:47.475>able <00:30:47.675>to <00:30:47.875>solve <00:30:48.075>our <00:30:48.275>problem

668
00:30:48.595 --> 00:30:50.575
<00:30:48.595>by <00:30:48.945>saying <00:30:49.295>dot <00:30:49.645>bind <00:30:49.995>this.

669
00:30:51.885 --> 00:30:54.105
<00:30:51.885>Now <00:30:52.060>there's <00:30:52.235>another <00:30:52.410>way <00:30:52.585>that <00:30:52.760>we <00:30:52.935>can <00:30:53.110>control <00:30:53.285>this.

670
00:30:54.525 --> 00:30:55.825
<00:30:54.525>It <00:30:54.817>is <00:30:55.110>with <00:30:55.402>arrow <00:30:55.695>functions.

671
00:30:56.285 --> 00:30:58.025
<00:30:56.285>Now <00:30:56.565>arrow <00:30:56.845>functions <00:30:57.125>are <00:30:57.405>great <00:30:57.685>in

672
00:30:58.025 --> 00:31:02.265
<00:30:58.025>that <00:30:58.165>they <00:30:58.305>grab <00:30:58.445>the <00:30:58.585>this <00:30:58.725>at <00:30:58.865>the <00:30:59.005>point <00:30:59.145>where <00:30:59.285>they're <00:30:59.425>created.

673
00:31:02.845 --> 00:31:05.345
<00:31:02.845>So <00:31:02.985>we <00:31:03.125>can <00:31:03.265>think <00:31:03.405>of <00:31:03.545>this <00:31:03.685>much <00:31:03.825>like <00:31:03.965>DOT <00:31:04.105>buying <00:31:04.245>this

674
00:31:05.925 --> 00:31:07.145
<00:31:05.925>at <00:31:06.144>the <00:31:06.364>point <00:31:06.583>where <00:31:06.803>it's <00:31:07.023>created.

675
00:31:08.455 --> 00:31:10.795
<00:31:08.455>That's <00:31:08.655>cool. <00:31:08.855>Now <00:31:09.054>it <00:31:09.254>is <00:31:09.455>shorter <00:31:09.655>as <00:31:09.855>well,

676
00:31:11.055 --> 00:31:12.555
<00:31:11.055>but <00:31:11.325>one <00:31:11.595>of <00:31:11.865>the <00:31:12.135>major <00:31:12.405>features

677
00:31:12.655 --> 00:31:15.715
<00:31:12.655>or <00:31:12.855>concerns <00:31:13.055>with <00:31:13.254>arrow <00:31:13.455>functions <00:31:13.655>is <00:31:13.855>it <00:31:14.055>grabs

678
00:31:16.225 --> 00:31:19.875
<00:31:16.225>this <00:31:16.352>at <00:31:16.479>the <00:31:16.606>point <00:31:16.734>where <00:31:16.861>it's <00:31:16.988>created <00:31:17.115>much <00:31:17.243>like <00:31:17.370>if <00:31:17.497>I <00:31:17.625>were

679
00:31:19.875 --> 00:31:21.635
<00:31:19.875>to <00:31:20.108>say <00:31:20.341>dot <00:31:20.575>bin <00:31:20.808>this <00:31:21.041>straight <00:31:21.275>away.

680
00:31:22.415 --> 00:31:24.635
<00:31:22.415>So <00:31:22.648>we've <00:31:22.881>already <00:31:23.115>packaged <00:31:23.348>that <00:31:23.581>function <00:31:23.815>together

681
00:31:24.635 --> 00:31:25.915
<00:31:24.635>with <00:31:24.923>this <00:31:25.211>in <00:31:25.499>that <00:31:25.787>envelope.

682
00:31:27.895 --> 00:31:30.115
<00:31:27.895>So <00:31:28.070>let's <00:31:28.245>do <00:31:28.420>that. <00:31:28.595>Let's <00:31:28.770>create <00:31:28.945>this <00:31:29.120>arrow <00:31:29.295>function

683
00:31:30.215 --> 00:31:32.475
<00:31:30.215>and <00:31:30.389>we'll <00:31:30.564>use <00:31:30.740>that <00:31:30.915>in <00:31:31.090>all <00:31:31.264>of <00:31:31.439>the <00:31:31.615>places.

684
00:31:32.895 --> 00:31:35.235
<00:31:32.895>Now <00:31:33.022>I <00:31:33.149>could <00:31:33.276>have <00:31:33.404>defined <00:31:33.531>this <00:31:33.658>in <00:31:33.785>line <00:31:33.913>as <00:31:34.040>an <00:31:34.167>arrow <00:31:34.295>function

685
00:31:35.335 --> 00:31:36.915
<00:31:35.335>or <00:31:35.535>I <00:31:35.735>could <00:31:35.935>have <00:31:36.135>defined <00:31:36.335>it <00:31:36.535>out <00:31:36.735>here.

686
00:31:37.135 --> 00:31:38.315
<00:31:37.135>The <00:31:37.400>result <00:31:37.666>is <00:31:37.931>the <00:31:38.197>same.

687
00:31:38.865 --> 00:31:41.235
<00:31:38.865>What <00:31:39.020>is <00:31:39.176>this <00:31:39.331>at <00:31:39.487>the <00:31:39.642>point <00:31:39.798>where <00:31:39.953>that <00:31:40.109>is <00:31:40.265>created?

688
00:31:41.705 --> 00:31:42.795
<00:31:41.705>It's <00:31:42.032>the <00:31:42.359>global <00:31:42.686>object.

689
00:31:43.535 --> 00:31:47.195
<00:31:43.535>So <00:31:43.690>when <00:31:43.846>we <00:31:44.001>call <00:31:44.157>AB <00:31:44.312>one <00:31:44.468>speak, <00:31:44.623>what <00:31:44.779>is <00:31:44.935>this?

690
00:31:47.345 --> 00:31:50.475
<00:31:47.345>Well, <00:31:47.520>it <00:31:47.695>was <00:31:47.870>already <00:31:48.045>bound <00:31:48.220>when <00:31:48.395>we <00:31:48.570>created <00:31:48.745>this.

691
00:31:51.015 --> 00:31:54.785
<00:31:51.015>So <00:31:51.170>it's <00:31:51.326>no <00:31:51.481>longer <00:31:51.637>AB <00:31:51.792>one, <00:31:51.948>it's <00:31:52.103>the <00:31:52.259>global <00:31:52.415>object

692
00:31:54.885 --> 00:31:56.945
<00:31:54.885>and <00:31:55.085>we <00:31:55.285>get <00:31:55.485>ninja <00:31:55.685>all <00:31:55.885>the <00:31:56.085>way <00:31:56.285>through.

693
00:31:57.695 --> 00:31:59.545
<00:31:57.695>Well <00:31:57.975>that <00:31:58.254>wasn't <00:31:58.534>the <00:31:58.814>expected <00:31:59.095>result.

694
00:32:00.175 --> 00:32:01.185
<00:32:00.175>Well <00:32:00.356>what <00:32:00.538>if <00:32:00.720>we <00:32:00.902>do <00:32:01.083>this?

695
00:32:01.185 --> 00:32:03.625
<00:32:01.185>What <00:32:01.340>if <00:32:01.496>we <00:32:01.651>say <00:32:01.807>OB <00:32:01.962>two <00:32:02.118>speak <00:32:02.273>equals <00:32:02.429>OB <00:32:02.585>two

696
00:32:03.675 --> 00:32:05.065
<00:32:03.675>speak, <00:32:04.092>bind <00:32:04.509>OB <00:32:04.926>two.

697
00:32:06.005 --> 00:32:08.825
<00:32:06.005>We <00:32:06.180>had <00:32:06.355>that <00:32:06.530>envelope <00:32:06.705>with <00:32:06.880>the <00:32:07.055>this <00:32:07.230>already <00:32:07.405>defined

698
00:32:08.885 --> 00:32:10.865
<00:32:08.885>and <00:32:09.085>we <00:32:09.285>put <00:32:09.485>it <00:32:09.685>inside <00:32:09.885>of <00:32:10.085>another <00:32:10.285>envelope.

699
00:32:12.005 --> 00:32:13.625
<00:32:12.005>So <00:32:12.238>as <00:32:12.471>we <00:32:12.705>go <00:32:12.938>to <00:32:13.171>execute <00:32:13.405>this,

700
00:32:14.045 --> 00:32:16.425
<00:32:14.045>we <00:32:14.278>will <00:32:14.511>unwrap <00:32:14.745>the <00:32:14.978>outer <00:32:15.211>O <00:32:15.445>envelope,

701
00:32:16.695 --> 00:32:18.385
<00:32:16.695>then <00:32:16.975>we'll <00:32:17.254>unwrap <00:32:17.534>the <00:32:17.814>inner <00:32:18.095>envelope

702
00:32:18.385 --> 00:32:21.385
<00:32:18.385>where <00:32:18.585>the <00:32:18.785>inner <00:32:18.985>envelope <00:32:19.185>already <00:32:19.385>has <00:32:19.585>this <00:32:19.785>set

703
00:32:21.405 --> 00:32:22.465
<00:32:21.405>at <00:32:21.723>the <00:32:22.041>global <00:32:22.359>object.

704
00:32:23.245 --> 00:32:25.385
<00:32:23.245>So <00:32:23.445>this <00:32:23.645>doesn't <00:32:23.844>change <00:32:24.044>our <00:32:24.245>result <00:32:24.445>at <00:32:24.645>all.

705
00:32:25.765 --> 00:32:28.185
<00:32:25.765>We <00:32:25.920>still <00:32:26.076>get <00:32:26.231>the <00:32:26.387>global <00:32:26.542>object <00:32:26.698>in <00:32:26.853>all <00:32:27.009>the <00:32:27.165>things

706
00:32:28.885 --> 00:32:32.945
<00:32:28.885>we <00:32:29.025>can't <00:32:29.165>override <00:32:29.305>the <00:32:29.445>binding <00:32:29.585>that <00:32:29.725>an <00:32:29.865>arrow <00:32:30.004>function <00:32:30.145>gave <00:32:30.285>us

707
00:32:33.455 --> 00:32:36.985
<00:32:33.455>when <00:32:33.610>we <00:32:33.766>create <00:32:33.921>a <00:32:34.077>new <00:32:34.232>binding <00:32:34.388>on <00:32:34.543>top <00:32:34.699>of <00:32:34.855>it.

708
00:32:38.695 --> 00:32:41.525
<00:32:38.695>Yeah, <00:32:38.895>arrow <00:32:39.095>functions <00:32:39.294>caused <00:32:39.495>an <00:32:39.695>interesting <00:32:39.895>concern <00:32:40.095>here

709
00:32:41.525 --> 00:32:45.305
<00:32:41.525>that <00:32:41.641>didn't <00:32:41.758>help <00:32:41.875>us, <00:32:41.991>but <00:32:42.108>let's <00:32:42.225>see <00:32:42.341>if <00:32:42.458>we <00:32:42.575>can <00:32:42.691>use <00:32:42.808>that <00:32:42.925>here.

710
00:32:45.715 --> 00:32:47.065
<00:32:45.715>Let's <00:32:46.018>use <00:32:46.322>an <00:32:46.626>arrow <00:32:46.930>function.

711
00:32:47.405 --> 00:32:49.065
<00:32:47.405>Now <00:32:47.605>I'm <00:32:47.805>using <00:32:48.004>an <00:32:48.205>arrow <00:32:48.405>function <00:32:48.605>in <00:32:48.805>here,

712
00:32:49.125 --> 00:32:50.945
<00:32:49.125>but <00:32:49.300>I'm <00:32:49.475>not <00:32:49.650>using <00:32:49.825>an <00:32:50.000>arrow <00:32:50.175>function <00:32:50.350>out <00:32:50.525>here.

713
00:32:50.965 --> 00:32:52.825
<00:32:50.965>We <00:32:51.198>saw <00:32:51.431>how <00:32:51.665>that <00:32:51.898>caused <00:32:52.131>problems <00:32:52.365>before,

714
00:32:53.125 --> 00:32:54.425
<00:32:53.125>but <00:32:53.320>now <00:32:53.514>we <00:32:53.710>have <00:32:53.905>a <00:32:54.100>speak <00:32:54.295>function

715
00:32:54.485 --> 00:32:56.865
<00:32:54.485>that's <00:32:54.685>gonna <00:32:54.885>grab <00:32:55.084>the <00:32:55.284>this <00:32:55.485>at <00:32:55.685>the <00:32:55.885>point

716
00:32:56.865 --> 00:32:58.385
<00:32:56.865>where <00:32:57.138>this <00:32:57.412>arrow <00:32:57.685>function <00:32:57.959>is <00:32:58.233>defined.

717
00:32:58.805 --> 00:33:02.605
<00:32:58.805>And <00:32:58.932>so <00:32:59.059>let's <00:32:59.186>see <00:32:59.314>if <00:32:59.441>that <00:32:59.568>works <00:32:59.695>as <00:32:59.823>expected <00:32:59.950>AB <00:33:00.077>one <00:33:00.205>speak.

718
00:33:03.195 --> 00:33:06.605
<00:33:03.195>Okay, <00:33:03.302>so <00:33:03.410>AB <00:33:03.518>one <00:33:03.625>is <00:33:03.733>the <00:33:03.841>this <00:33:03.948>as <00:33:04.056>we <00:33:04.164>enter, <00:33:04.271>I'm <00:33:04.379>gonna <00:33:04.487>go <00:33:04.595>grab

719
00:33:06.605 --> 00:33:08.365
<00:33:06.605>that, <00:33:06.885>this <00:33:07.165>with <00:33:07.445>this <00:33:07.725>arrow <00:33:08.005>function

720
00:33:08.505 --> 00:33:11.205
<00:33:08.505>and <00:33:08.660>in <00:33:08.816>a <00:33:08.971>hundred <00:33:09.127>milliseconds <00:33:09.282>AB <00:33:09.438>one <00:33:09.593>is <00:33:09.749>the <00:33:09.905>this

721
00:33:11.205 --> 00:33:14.445
<00:33:11.205>that <00:33:11.345>we <00:33:11.485>bound <00:33:11.625>into <00:33:11.764>place <00:33:11.905>and <00:33:12.044>we <00:33:12.185>will <00:33:12.324>correctly <00:33:12.465>get <00:33:12.605>doctor.

722
00:33:16.065 --> 00:33:20.265
<00:33:16.065>Very <00:33:16.220>nice. <00:33:16.376>So <00:33:16.531>we <00:33:16.687>were <00:33:16.842>able <00:33:16.998>to <00:33:17.153>solve <00:33:17.309>our <00:33:17.465>problem

723
00:33:20.335 --> 00:33:21.905
<00:33:20.335>with <00:33:20.615>an <00:33:20.895>arrow <00:33:21.175>function <00:33:21.455>in <00:33:21.735>here,

724
00:33:22.405 --> 00:33:24.305
<00:33:22.405>but <00:33:22.638>not <00:33:22.871>an <00:33:23.105>arrow <00:33:23.338>function <00:33:23.571>out <00:33:23.805>here.

725
00:33:25.045 --> 00:33:26.865
<00:33:25.045>Yes, <00:33:25.245>we <00:33:25.445>may <00:33:25.645>need <00:33:25.845>a <00:33:26.045>comment <00:33:26.245>here <00:33:26.445>to

726
00:33:27.605 --> 00:33:29.665
<00:33:27.605>detail <00:33:27.780>why <00:33:27.955>we <00:33:28.130>chose <00:33:28.305>to <00:33:28.480>do <00:33:28.655>it <00:33:28.830>this <00:33:29.005>way.

727
00:33:29.885 --> 00:33:31.545
<00:33:29.885>It <00:33:30.040>might <00:33:30.196>be <00:33:30.351>easy <00:33:30.507>for <00:33:30.662>us <00:33:30.818>to <00:33:30.973>just <00:33:31.129>go <00:33:31.285>through

728
00:33:31.565 --> 00:33:33.785
<00:33:31.565>and <00:33:31.765>replace <00:33:31.965>all <00:33:32.165>of <00:33:32.365>the <00:33:32.565>functions <00:33:32.765>with <00:33:32.965>arrows

729
00:33:34.085 --> 00:33:36.505
<00:33:34.085>and <00:33:34.285>now <00:33:34.485>suddenly <00:33:34.685>our <00:33:34.885>code <00:33:35.085>doesn't <00:33:35.285>work <00:33:35.485>anymore

730
00:33:36.505 --> 00:33:39.385
<00:33:36.505>because <00:33:36.660>we <00:33:36.816>bound <00:33:36.971>all <00:33:37.127>of <00:33:37.282>the <00:33:37.438>this <00:33:37.593>at <00:33:37.749>the <00:33:37.905>point

731
00:33:39.385 --> 00:33:40.385
<00:33:39.385>where <00:33:39.685>we've <00:33:39.985>created <00:33:40.285>them

732
00:33:40.925 --> 00:33:43.905
<00:33:40.925>and <00:33:41.100>even <00:33:41.274>doing <00:33:41.450>a <00:33:41.625>dot <00:33:41.800>bind <00:33:41.975>won't <00:33:42.149>override <00:33:42.325>that.

733
00:33:44.075 --> 00:33:47.505
<00:33:44.075>We've <00:33:44.202>already <00:33:44.329>bound <00:33:44.456>it. <00:33:44.584>So <00:33:44.711>this <00:33:44.838>one <00:33:44.965>is <00:33:45.093>not <00:33:45.220>an <00:33:45.347>arrow <00:33:45.475>function

734
00:33:47.685 --> 00:33:49.505
<00:33:47.685>and <00:33:47.918>this <00:33:48.151>one <00:33:48.385>is <00:33:48.618>an <00:33:48.851>arrow <00:33:49.085>function.

735
00:33:50.225 --> 00:33:53.885
<00:33:50.225>Perfect. <00:33:50.425>We <00:33:50.625>have <00:33:50.824>to <00:33:51.024>see <00:33:51.225>how <00:33:51.425>arrow <00:33:51.625>functions

736
00:33:54.265 --> 00:33:55.285
<00:33:54.265>and <00:33:55.183>bind

737
00:33:55.425 --> 00:33:59.045
<00:33:55.425>and <00:33:55.552>call <00:33:55.679>allow <00:33:55.806>us <00:33:55.934>to <00:33:56.061>change <00:33:56.188>this <00:33:56.315>where <00:33:56.443>this <00:33:56.570>is <00:33:56.697>the <00:33:56.825>thing

738
00:33:59.045 --> 00:34:00.045
<00:33:59.045>to <00:33:59.225>the <00:33:59.405>left <00:33:59.585>of <00:33:59.765>the <00:33:59.945>dot.

739
00:34:00.425 --> 00:34:01.965
<00:34:00.425>Now <00:34:00.598>let's <00:34:00.771>take <00:34:00.944>a <00:34:01.118>look <00:34:01.291>at <00:34:01.464>the <00:34:01.637>event <00:34:01.811>loop.

740
00:34:03.085 --> 00:34:04.085
<00:34:03.085>I <00:34:03.385>love <00:34:03.685>this <00:34:03.985>website

741
00:34:04.085 --> 00:34:06.485
<00:34:04.085>because <00:34:04.260>it's <00:34:04.435>a <00:34:04.610>great <00:34:04.785>way <00:34:04.960>to <00:34:05.135>visualize <00:34:05.310>the <00:34:05.485>event

742
00:34:06.485 --> 00:34:08.005
<00:34:06.485>loop <00:34:07.169>we <00:34:07.853>have.

743
00:34:08.305 --> 00:34:11.205
<00:34:08.304>Um, <00:34:08.480>here's <00:34:08.654>the <00:34:08.830>author <00:34:09.004>who <00:34:09.179>actually <00:34:09.355>built <00:34:09.529>this <00:34:09.705>site

744
00:34:11.225 --> 00:34:13.005
<00:34:11.225>and <00:34:11.458>it <00:34:11.691>is, <00:34:11.924>that's <00:34:12.158>an <00:34:12.391>amazing <00:34:12.625>talk.

745
00:34:13.985 --> 00:34:17.205
<00:34:13.985>We <00:34:14.140>have <00:34:14.296>the <00:34:14.451>call <00:34:14.607>stack. <00:34:14.762>That's <00:34:14.918>what's <00:34:15.073>executing <00:34:15.229>right <00:34:15.385>now.

746
00:34:18.315 --> 00:34:21.095
<00:34:18.315>Now <00:34:18.490>anything <00:34:18.665>that <00:34:18.840>is <00:34:19.014>scheduled <00:34:19.190>to <00:34:19.365>happen <00:34:19.540>later, <00:34:19.715>either

747
00:34:21.095 --> 00:34:22.095
<00:34:21.094>with <00:34:21.395>a <00:34:21.694>button <00:34:21.995>click

748
00:34:22.115 --> 00:34:25.775
<00:34:22.114>or <00:34:22.270>with <00:34:22.426>a <00:34:22.581>set <00:34:22.737>timeout <00:34:22.892>happens <00:34:23.048>over <00:34:23.203>here <00:34:23.359>where <00:34:23.514>those,

749
00:34:26.255 --> 00:34:27.775
<00:34:26.255>whenever <00:34:26.528>they <00:34:26.802>finish, <00:34:27.075>they'll <00:34:27.349>get <00:34:27.623>put

750
00:34:27.775 --> 00:34:29.015
<00:34:27.775>into <00:34:28.147>this <00:34:28.518>callback <00:34:28.891>queue.

751
00:34:29.795 --> 00:34:32.095
<00:34:29.795>Now <00:34:30.028>this <00:34:30.261>callback <00:34:30.495>queue <00:34:30.728>will <00:34:30.961>get <00:34:31.195>run

752
00:34:32.895 --> 00:34:34.535
<00:34:32.895>whenever <00:34:33.175>the <00:34:33.455>call <00:34:33.735>stack <00:34:34.014>is <00:34:34.295>empty.

753
00:34:34.875 --> 00:34:37.375
<00:34:34.875>So <00:34:35.074>let's <00:34:35.275>go <00:34:35.475>grab <00:34:35.675>this <00:34:35.875>content <00:34:36.074>right <00:34:36.275>here

754
00:34:37.675 --> 00:34:38.735
<00:34:37.675>and <00:34:37.993>let's <00:34:38.311>execute <00:34:38.629>it.

755
00:34:40.225 --> 00:34:43.685
<00:34:40.225>Now <00:34:40.424>this <00:34:40.625>is, <00:34:40.824>um, <00:34:41.025>the <00:34:41.225>great <00:34:41.424>example <00:34:41.625>of

756
00:34:43.685 --> 00:34:45.845
<00:34:43.685>what <00:34:43.860>happens <00:34:44.034>when <00:34:44.210>you <00:34:44.384>count <00:34:44.560>from <00:34:44.735>one <00:34:44.909>to <00:34:45.085>10

757
00:34:46.305 --> 00:34:49.205
<00:34:46.304>and <00:34:46.460>then <00:34:46.616>wait <00:34:46.771>a <00:34:46.927>little <00:34:47.082>bit <00:34:47.238>and <00:34:47.393>then <00:34:47.549>output <00:34:47.705>them.

758
00:34:49.505 --> 00:34:51.805
<00:34:49.505>Of <00:34:49.660>course, <00:34:49.816>we're <00:34:49.971>gonna <00:34:50.127>get <00:34:50.282>10 <00:34:50.438>in <00:34:50.593>all <00:34:50.749>the <00:34:50.905>places,

759
00:34:52.145 --> 00:34:53.165
<00:34:52.145>but <00:34:52.374>let's <00:34:52.603>watch <00:34:52.833>it <00:34:53.063>happen.

760
00:34:54.065 --> 00:34:55.765
<00:34:54.065>Now <00:34:54.415>as <00:34:54.764>we're <00:34:55.115>executing <00:34:55.465>here,

761
00:34:56.135 --> 00:34:57.885
<00:34:56.135>we're <00:34:56.415>still <00:34:56.695>running <00:34:56.975>our <00:34:57.255>account <00:34:57.535>function.

762
00:34:58.305 --> 00:35:00.845
<00:34:58.305>All <00:34:58.504>of <00:34:58.705>these <00:34:58.904>show <00:34:59.105>methods <00:34:59.305>are <00:34:59.504>getting <00:34:59.705>queued.

763
00:35:01.155 --> 00:35:04.645
<00:35:01.155>They <00:35:01.330>aren't <00:35:01.505>run <00:35:01.680>until <00:35:01.855>this <00:35:02.030>call <00:35:02.205>stack <00:35:02.380>is <00:35:02.555>empty.

764
00:35:05.185 --> 00:35:07.085
<00:35:05.185>So <00:35:05.418>yep, <00:35:05.651>we're <00:35:05.884>gonna <00:35:06.118>keep <00:35:06.351>counting <00:35:06.585>up,

765
00:35:07.085 --> 00:35:09.085
<00:35:07.085>we're <00:35:07.318>gonna <00:35:07.551>keep <00:35:07.785>putting <00:35:08.018>them <00:35:08.251>here <00:35:08.485>and

766
00:35:09.325 --> 00:35:12.085
<00:35:09.325>whenever <00:35:09.500>they're <00:35:09.674>ready, <00:35:09.850>then <00:35:10.024>they'll <00:35:10.200>go <00:35:10.375>into <00:35:10.549>callback <00:35:10.725>queue.

767
00:35:12.675 --> 00:35:14.285
<00:35:12.675>Once <00:35:12.955>the <00:35:13.235>call <00:35:13.515>stack <00:35:13.795>is <00:35:14.075>empty,

768
00:35:14.315 --> 00:35:17.085
<00:35:14.315>then <00:35:14.470>the <00:35:14.626>callback <00:35:14.781>queue <00:35:14.937>will <00:35:15.092>get <00:35:15.248>emptied <00:35:15.403>one <00:35:15.559>at <00:35:15.715>a

769
00:35:17.085 --> 00:35:18.565
<00:35:17.085>time <00:35:17.418>into <00:35:17.751>our <00:35:18.084>call <00:35:18.417>stack.

770
00:35:19.995 --> 00:35:23.695
<00:35:19.995>Now <00:35:20.102>that <00:35:20.210>does <00:35:20.318>mean <00:35:20.425>that <00:35:20.533>if <00:35:20.641>we <00:35:20.748>say <00:35:20.856>set <00:35:20.964>timeout <00:35:21.071>in <00:35:21.179>this <00:35:21.287>case <00:35:21.395>a

771
00:35:23.695 --> 00:35:25.575
<00:35:23.695>hundred, <00:35:24.045>uh, <00:35:24.395>a <00:35:24.745>thousand <00:35:25.095>milliseconds,

772
00:35:25.715 --> 00:35:27.935
<00:35:25.715>it <00:35:25.915>may <00:35:26.115>not <00:35:26.315>happen <00:35:26.515>in <00:35:26.715>a <00:35:26.915>thousand <00:35:27.115>milliseconds.

773
00:35:28.265 --> 00:35:30.495
<00:35:28.265>Maybe <00:35:28.615>it'll <00:35:28.964>happen <00:35:29.315>in <00:35:29.665>two

774
00:35:30.495 --> 00:35:33.015
<00:35:30.495>or <00:35:30.694>three <00:35:30.895>seconds, <00:35:31.095>five <00:35:31.295>seconds <00:35:31.495>whenever <00:35:31.694>it's <00:35:31.895>done.

775
00:35:33.555 --> 00:35:35.895
<00:35:33.555>Now <00:35:33.694>that <00:35:33.835>we're <00:35:33.975>done, <00:35:34.115>now <00:35:34.254>we'll <00:35:34.395>pull <00:35:34.535>the <00:35:34.674>next <00:35:34.815>thing <00:35:34.955>out

776
00:35:35.895 --> 00:35:38.325
<00:35:35.895>of <00:35:36.050>the <00:35:36.206>callback <00:35:36.361>queue <00:35:36.517>and <00:35:36.672>we'll <00:35:36.828>start <00:35:36.983>to <00:35:37.139>execute <00:35:37.295>that.

777
00:35:39.755 --> 00:35:42.175
<00:35:39.755>So <00:35:39.910>what <00:35:40.066>are <00:35:40.221>we <00:35:40.377>getting <00:35:40.532>when <00:35:40.688>we <00:35:40.843>console <00:35:40.999>log <00:35:41.155>here?

778
00:35:42.365 --> 00:35:45.975
<00:35:42.365>Well, <00:35:42.540>yeah, <00:35:42.714>we're <00:35:42.890>getting <00:35:43.064>10 <00:35:43.240>because <00:35:43.415>we <00:35:43.589>finished <00:35:43.765>counting

779
00:35:46.835 --> 00:35:49.735
<00:35:46.835>and <00:35:46.990>now <00:35:47.146>I <00:35:47.301>is <00:35:47.457>10 <00:35:47.612>in <00:35:47.768>all <00:35:47.923>of <00:35:48.079>the <00:35:48.235>places.

780
00:35:51.915 --> 00:35:53.925
<00:35:51.915>That <00:35:52.042>was <00:35:52.169>really <00:35:52.296>fun <00:35:52.424>to <00:35:52.551>be <00:35:52.678>able <00:35:52.805>to <00:35:52.933>see <00:35:53.060>the <00:35:53.187>call <00:35:53.315>stack,

781
00:35:54.065 --> 00:35:56.685
<00:35:54.065>the <00:35:54.298>callback <00:35:54.531>queue <00:35:54.765>and <00:35:54.998>the <00:35:55.231>web <00:35:55.465>APIs.

782
00:35:57.955 --> 00:36:01.735
<00:35:57.955>As <00:35:58.095>we <00:35:58.235>take <00:35:58.375>a <00:35:58.515>look <00:35:58.654>through, <00:35:58.795>um, <00:35:58.935>JavaScript, <00:35:59.075>we <00:35:59.215>can <00:35:59.355>see

783
00:36:01.735 --> 00:36:03.855
<00:36:01.735>that <00:36:01.935>mechanism <00:36:02.135>where <00:36:02.335>you <00:36:02.535>have <00:36:02.735>that <00:36:02.935>gooey <00:36:03.135>stack.

784
00:36:04.045 --> 00:36:07.215
<00:36:04.045>Once <00:36:04.172>the <00:36:04.299>gooey <00:36:04.426>stack <00:36:04.554>is <00:36:04.681>empty, <00:36:04.808>we'll <00:36:04.935>call <00:36:05.063>the <00:36:05.190>next <00:36:05.317>one <00:36:05.445>out

785
00:36:07.215 --> 00:36:08.935
<00:36:07.215>of <00:36:07.415>the <00:36:07.615>callback <00:36:07.815>queue <00:36:08.015>into <00:36:08.215>the <00:36:08.415>gooey <00:36:08.615>stack

786
00:36:09.115 --> 00:36:10.175
<00:36:09.115>and <00:36:09.433>we'll <00:36:09.751>execute <00:36:10.069>that.

787
00:36:11.415 --> 00:36:15.175
<00:36:11.415>Anything <00:36:11.570>that's <00:36:11.726>waiting, <00:36:11.881>uh, <00:36:12.037>Ajax <00:36:12.192>call <00:36:12.348>or <00:36:12.503>a <00:36:12.659>set <00:36:12.815>timeout

788
00:36:15.315 --> 00:36:17.695
<00:36:15.315>or <00:36:15.595>anything <00:36:15.875>calling <00:36:16.155>an <00:36:16.435>external <00:36:16.715>API.

789
00:36:18.005 --> 00:36:20.255
<00:36:18.005>Once <00:36:18.160>it's <00:36:18.316>done, <00:36:18.471>it <00:36:18.627>will <00:36:18.782>go <00:36:18.938>into <00:36:19.093>the <00:36:19.249>callback <00:36:19.405>queue

790
00:36:20.475 --> 00:36:22.815
<00:36:20.475>and <00:36:20.630>wait <00:36:20.786>for <00:36:20.941>the <00:36:21.097>gooey <00:36:21.252>stack <00:36:21.408>to <00:36:21.563>be <00:36:21.719>empty <00:36:21.875>so

791
00:36:22.815 --> 00:36:24.215
<00:36:22.815>that <00:36:22.995>it <00:36:23.175>can <00:36:23.355>move <00:36:23.535>into <00:36:23.715>the <00:36:23.895>gooey <00:36:24.075>stack.

792
00:36:24.895 --> 00:36:27.595
<00:36:24.895>As <00:36:25.035>you <00:36:25.175>grab <00:36:25.315>these <00:36:25.455>slides <00:36:25.595>from <00:36:25.735>robert <00:36:25.875>rich.org, <00:36:26.015>you <00:36:26.155>can <00:36:26.295>read

793
00:36:27.615 --> 00:36:29.115
<00:36:27.615>or <00:36:27.839>watch <00:36:28.064>more <00:36:28.290>about <00:36:28.515>the <00:36:28.740>event <00:36:28.964>loop.

794
00:36:29.735 --> 00:36:32.155
<00:36:29.735>So <00:36:29.875>now <00:36:30.015>let's <00:36:30.155>look <00:36:30.295>at <00:36:30.435>how <00:36:30.575>the <00:36:30.715>node <00:36:30.855>event <00:36:30.995>loop <00:36:31.135>works.

795
00:36:32.855 --> 00:36:35.915
<00:36:32.855>Now <00:36:33.010>each <00:36:33.166>request <00:36:33.321>kind <00:36:33.477>of <00:36:33.632>has <00:36:33.788>one <00:36:33.943>of <00:36:34.099>those <00:36:34.255>stats.

796
00:36:36.175 --> 00:36:38.355
<00:36:36.175>Now <00:36:36.408>this <00:36:36.641>is <00:36:36.875>definitely <00:36:37.108>the <00:36:37.341>logical <00:36:37.575>implementation,

797
00:36:38.415 --> 00:36:39.835
<00:36:38.415>not <00:36:38.841>the <00:36:39.267>physical <00:36:39.693>implementation.

798
00:36:40.295 --> 00:36:42.355
<00:36:40.295>But <00:36:40.575>what <00:36:40.855>if <00:36:41.135>this <00:36:41.415>request <00:36:41.695>is

799
00:36:42.355 --> 00:36:43.515
<00:36:42.355>gonna <00:36:42.529>count <00:36:42.703>from <00:36:42.877>one <00:36:43.051>to <00:36:43.225>a <00:36:43.399>billion?

800
00:36:44.865 --> 00:36:47.155
<00:36:44.865>Well, <00:36:45.214>JavaScript <00:36:45.564>is <00:36:45.915>single <00:36:46.265>threaded.

801
00:36:47.335 --> 00:36:50.795
<00:36:47.335>So <00:36:47.462>note <00:36:47.589>is <00:36:47.716>just <00:36:47.844>gonna <00:36:47.971>sit <00:36:48.098>on <00:36:48.225>this <00:36:48.353>request <00:36:48.480>waiting <00:36:48.607>for <00:36:48.735>it

802
00:36:50.795 --> 00:36:53.775
<00:36:50.795>to <00:36:50.950>finish, <00:36:51.106>and <00:36:51.261>then <00:36:51.417>once <00:36:51.572>it <00:36:51.728>finishes, <00:36:51.883>it'll <00:36:52.039>go <00:36:52.195>through

803
00:36:54.135 --> 00:36:56.535
<00:36:54.135>and <00:36:54.310>push <00:36:54.485>the <00:36:54.660>next <00:36:54.835>things <00:36:55.010>to <00:36:55.185>the <00:36:55.360>next <00:36:55.535>phase.

804
00:36:56.835 --> 00:36:58.575
<00:36:56.835>So <00:36:57.068>once <00:36:57.301>our <00:36:57.535>gooey <00:36:57.768>stack <00:36:58.001>is <00:36:58.235>empty,

805
00:36:58.585 --> 00:37:00.815
<00:36:58.585>it'll <00:36:58.760>pull <00:36:58.935>the <00:36:59.110>next <00:36:59.285>thing <00:36:59.460>off <00:36:59.635>our <00:36:59.810>callback <00:36:59.985>queue

806
00:37:00.995 --> 00:37:02.455
<00:37:00.995>and <00:37:01.182>then <00:37:01.370>move <00:37:01.558>on <00:37:01.745>to <00:37:01.933>the <00:37:02.121>next <00:37:02.308>piece.

807
00:37:03.785 --> 00:37:05.805
<00:37:03.785>So <00:37:03.984>we <00:37:04.185>might <00:37:04.384>see <00:37:04.585>code <00:37:04.785>in <00:37:04.984>our <00:37:05.185>application

808
00:37:05.805 --> 00:37:07.845
<00:37:05.805>that <00:37:05.980>looks <00:37:06.154>like <00:37:06.330>this <00:37:06.504>set <00:37:06.680>time <00:37:06.855>out <00:37:07.029>of <00:37:07.205>zero.

809
00:37:08.495 --> 00:37:10.795
<00:37:08.495>Why <00:37:08.728>would <00:37:08.961>we <00:37:09.194>wait <00:37:09.428>zero <00:37:09.661>seconds <00:37:09.895>just

810
00:37:10.795 --> 00:37:12.155
<00:37:10.795>to <00:37:10.969>be <00:37:11.144>able <00:37:11.319>to <00:37:11.494>run <00:37:11.669>the <00:37:11.844>next <00:37:12.019>thing?

811
00:37:13.105 --> 00:37:15.435
<00:37:13.105>Well, <00:37:13.385>we're <00:37:13.665>yielding <00:37:13.945>our <00:37:14.225>thread <00:37:14.505>so

812
00:37:15.435 --> 00:37:18.155
<00:37:15.435>that <00:37:15.590>node <00:37:15.746>can <00:37:15.901>go <00:37:16.057>check <00:37:16.212>on <00:37:16.368>all <00:37:16.523>those <00:37:16.679>other <00:37:16.835>requests

813
00:37:18.295 --> 00:37:19.555
<00:37:18.295>and <00:37:18.484>then <00:37:18.673>come <00:37:18.862>back <00:37:19.051>to <00:37:19.240>our <00:37:19.429>process.

814
00:37:20.055 --> 00:37:22.235
<00:37:20.055>We <00:37:20.288>might <00:37:20.521>also <00:37:20.754>say <00:37:20.988>process <00:37:21.221>next, <00:37:21.455>tick.

815
00:37:22.535 --> 00:37:25.195
<00:37:22.535>And <00:37:22.674>you <00:37:22.815>can <00:37:22.955>either <00:37:23.095>pass <00:37:23.234>in <00:37:23.375>an <00:37:23.515>empty <00:37:23.654>function <00:37:23.795>or <00:37:23.935>nothing

816
00:37:25.535 --> 00:37:28.315
<00:37:25.535>and <00:37:25.734>then <00:37:25.935>await <00:37:26.134>that <00:37:26.335>we're <00:37:26.535>yielding <00:37:26.734>the <00:37:26.935>thread.

817
00:37:28.405 --> 00:37:30.235
<00:37:28.405>We're <00:37:28.638>being <00:37:28.871>a <00:37:29.105>good <00:37:29.338>net <00:37:29.571>citizen <00:37:29.805>so

818
00:37:30.235 --> 00:37:32.915
<00:37:30.235>that <00:37:30.375>node <00:37:30.515>can <00:37:30.655>go <00:37:30.795>check <00:37:30.935>on <00:37:31.075>all <00:37:31.215>of <00:37:31.355>the <00:37:31.495>other <00:37:31.635>requests

819
00:37:33.055 --> 00:37:36.075
<00:37:33.055>and <00:37:33.194>we <00:37:33.335>didn't <00:37:33.475>lock <00:37:33.615>up <00:37:33.754>the <00:37:33.895>thread <00:37:34.035>while <00:37:34.174>we're <00:37:34.315>executing <00:37:34.455>our

820
00:37:36.075 --> 00:37:37.195
<00:37:36.075>really <00:37:36.411>long <00:37:36.747>running <00:37:37.083>task.

821
00:37:38.175 --> 00:37:40.155
<00:37:38.175>That's <00:37:38.330>a <00:37:38.486>really <00:37:38.641>good <00:37:38.797>way <00:37:38.952>to <00:37:39.108>be <00:37:39.263>able <00:37:39.419>to <00:37:39.575>go

822
00:37:40.415 --> 00:37:43.075
<00:37:40.415>to <00:37:40.615>make <00:37:40.815>our <00:37:41.015>system <00:37:41.215>more <00:37:41.415>performant <00:37:41.615>in <00:37:41.815>this

823
00:37:43.075 --> 00:37:44.235
<00:37:43.075>single-threaded <00:37:44.119>environment.

824
00:37:45.865 --> 00:37:47.325
<00:37:45.865>We <00:37:46.052>got <00:37:46.240>to <00:37:46.428>see <00:37:46.615>the <00:37:46.803>node <00:37:46.991>event <00:37:47.178>loop

825
00:37:47.385 --> 00:37:50.725
<00:37:47.385>and <00:37:47.540>how <00:37:47.696>yielding <00:37:47.851>the <00:37:48.007>thread <00:37:48.162>can <00:37:48.318>make <00:37:48.473>a <00:37:48.629>website <00:37:48.785>feel

826
00:37:51.005 --> 00:37:52.085
<00:37:51.005>more <00:37:51.977>responsive.

827
00:37:52.345 --> 00:37:53.925
<00:37:52.345>Now <00:37:52.625>it's <00:37:52.904>not <00:37:53.185>actually <00:37:53.464>running <00:37:53.745>faster,

828
00:37:54.265 --> 00:37:57.045
<00:37:54.265>but <00:37:54.381>it <00:37:54.498>is <00:37:54.615>getting <00:37:54.731>us <00:37:54.848>to <00:37:54.964>the <00:37:55.081>point <00:37:55.198>where <00:37:55.315>we <00:37:55.431>can <00:37:55.548>execute <00:37:55.665>more.

829
00:37:57.465 --> 00:37:59.525
<00:37:57.465>Now <00:37:57.620>let's <00:37:57.776>take <00:37:57.931>it, <00:37:58.087>take <00:37:58.242>a <00:37:58.398>look <00:37:58.553>at <00:37:58.709>Async <00:37:58.865>Await.

830
00:37:59.825 --> 00:38:02.885
<00:37:59.825>Do <00:37:59.924>we <00:38:00.024>have <00:38:00.125>to <00:38:00.225>wait <00:38:00.325>for <00:38:00.424>a <00:38:00.524>big <00:38:00.625>rewrite <00:38:00.725>to <00:38:00.825>be <00:38:00.924>able <00:38:01.024>to <00:38:01.125>use <00:38:01.225>Async

831
00:38:02.885 --> 00:38:04.365
<00:38:02.885>and <00:38:03.551>Await <00:38:04.216>Async?

832
00:38:04.365 --> 00:38:05.445
<00:38:04.365>And <00:38:04.689>Await <00:38:05.013>was <00:38:05.337>inspired

833
00:38:05.445 --> 00:38:07.965
<00:38:05.445>by <00:38:05.678>C <00:38:05.911>Sharp's <00:38:06.145>implementation <00:38:06.378>and <00:38:06.611>C <00:38:06.845>Sharp.

834
00:38:07.965 --> 00:38:09.205
<00:38:07.965>It's <00:38:08.151>built <00:38:08.337>on <00:38:08.523>top <00:38:08.709>of <00:38:08.895>the <00:38:09.081>task

835
00:38:09.725 --> 00:38:11.285
<00:38:09.725>parallel <00:38:10.191>library <00:38:10.658>in <00:38:11.125>JavaScript.

836
00:38:11.315 --> 00:38:13.405
<00:38:11.315>It's <00:38:11.515>built <00:38:11.715>on <00:38:11.915>top <00:38:12.115>of <00:38:12.315>promises <00:38:12.515>and <00:38:12.715>generators.

837
00:38:14.075 --> 00:38:16.765
<00:38:14.075>It's <00:38:14.274>this <00:38:14.475>Resumable <00:38:14.674>state <00:38:14.875>machine <00:38:15.075>that <00:38:15.274>knows <00:38:15.475>how

838
00:38:16.765 --> 00:38:18.125
<00:38:16.765>to <00:38:17.009>pick <00:38:17.254>up <00:38:17.499>and <00:38:17.744>continue <00:38:17.989>on.

839
00:38:18.425 --> 00:38:21.445
<00:38:18.425>It <00:38:18.580>is <00:38:18.736>asynchronous, <00:38:18.891>but <00:38:19.047>we <00:38:19.202>can <00:38:19.358>think <00:38:19.513>about <00:38:19.669>it <00:38:19.825>synchronously.

840
00:38:22.345 --> 00:38:23.965
<00:38:22.345>So <00:38:22.625>here's <00:38:22.904>our <00:38:23.185>promise <00:38:23.464>based <00:38:23.745>code

841
00:38:24.015 --> 00:38:25.645
<00:38:24.015>where <00:38:24.248>we <00:38:24.481>say <00:38:24.714>it <00:38:24.948>return <00:38:25.181>New <00:38:25.415>Promise,

842
00:38:26.105 --> 00:38:28.325
<00:38:26.105>and <00:38:26.338>then <00:38:26.571>once <00:38:26.805>we're <00:38:27.038>done <00:38:27.271>we'll <00:38:27.505>click,

843
00:38:28.655 --> 00:38:31.045
<00:38:28.655>we'll <00:38:28.888>call <00:38:29.121>Resolve <00:38:29.355>passing <00:38:29.588>in <00:38:29.821>the <00:38:30.055>results,

844
00:38:31.305 --> 00:38:32.365
<00:38:31.305>and <00:38:31.495>then <00:38:31.686>when <00:38:31.877>we <00:38:32.068>call <00:38:32.259>it,

845
00:38:32.365 --> 00:38:34.325
<00:38:32.365>we <00:38:32.520>can <00:38:32.676>dot <00:38:32.831>then <00:38:32.987>to <00:38:33.142>be <00:38:33.298>able <00:38:33.453>to <00:38:33.609>do <00:38:33.765>stuff.

846
00:38:35.545 --> 00:38:38.925
<00:38:35.545>Now, <00:38:35.720>that's <00:38:35.895>interesting, <00:38:36.070>but <00:38:36.245>we <00:38:36.420>have <00:38:36.595>this <00:38:36.770>dot <00:38:36.945>hon.

847
00:38:39.105 --> 00:38:41.885
<00:38:39.105>We <00:38:39.260>can't <00:38:39.416>actually <00:38:39.571>throw <00:38:39.727>things <00:38:39.882>we <00:38:40.038>have <00:38:40.193>to <00:38:40.349>call <00:38:40.505>reject.

848
00:38:42.345 --> 00:38:44.285
<00:38:42.345>So <00:38:42.520>let's <00:38:42.694>flip <00:38:42.870>it <00:38:43.044>over <00:38:43.220>to <00:38:43.395>Ayc <00:38:43.569>and <00:38:43.745>Await.

849
00:38:44.745 --> 00:38:47.765
<00:38:44.745>Now <00:38:44.884>we <00:38:45.025>do <00:38:45.165>have <00:38:45.305>this <00:38:45.444>async <00:38:45.585>in <00:38:45.725>front <00:38:45.865>of <00:38:46.005>our <00:38:46.145>function

850
00:38:47.765 --> 00:38:50.245
<00:38:47.765>that <00:38:47.940>tells <00:38:48.115>us <00:38:48.290>this <00:38:48.464>is <00:38:48.640>a, <00:38:48.815>an <00:38:48.990>asynchronous <00:38:49.165>process.

851
00:38:50.705 --> 00:38:52.805
<00:38:50.705>It <00:38:50.880>will <00:38:51.055>yield <00:38:51.230>the <00:38:51.404>thread <00:38:51.580>and, <00:38:51.755>and <00:38:51.930>come <00:38:52.105>back.

852
00:38:53.185 --> 00:38:56.005
<00:38:53.185>And <00:38:53.340>now <00:38:53.496>we <00:38:53.651>can <00:38:53.807>use <00:38:53.962>try <00:38:54.118>and <00:38:54.273>catch. <00:38:54.429>That's <00:38:54.585>excellent.

853
00:38:56.505 --> 00:38:59.565
<00:38:56.505>We <00:38:56.705>await <00:38:56.905>the <00:38:57.105>calls <00:38:57.305>into <00:38:57.505>the <00:38:57.705>other <00:38:57.905>libraries

854
00:38:59.705 --> 00:39:02.485
<00:38:59.705>and <00:38:59.860>once <00:39:00.016>they're <00:39:00.171>done, <00:39:00.327>then <00:39:00.482>we <00:39:00.638>can <00:39:00.793>return <00:39:00.949>those <00:39:01.105>results

855
00:39:02.665 --> 00:39:04.045
<00:39:02.665>and <00:39:02.872>we <00:39:03.079>still <00:39:03.286>get <00:39:03.493>a <00:39:03.700>call <00:39:03.907>stack.

856
00:39:04.495 --> 00:39:07.475
<00:39:04.495>That's <00:39:04.634>excellent. <00:39:04.775>So <00:39:04.915>do <00:39:05.055>we <00:39:05.194>need <00:39:05.335>to <00:39:05.475>wait <00:39:05.615>to <00:39:05.755>be <00:39:05.895>able

857
00:39:07.475 --> 00:39:11.035
<00:39:07.475>to <00:39:07.591>do <00:39:07.708>a <00:39:07.825>Big <00:39:07.941>Bang <00:39:08.058>refactor <00:39:08.174>before <00:39:08.291>we <00:39:08.408>can <00:39:08.525>use <00:39:08.641>Async <00:39:08.758>and <00:39:08.875>Await?

858
00:39:11.425 --> 00:39:13.555
<00:39:11.425>Well, <00:39:11.625>async <00:39:11.825>and <00:39:12.025>Await <00:39:12.225>is <00:39:12.425>built <00:39:12.625>on <00:39:12.825>top

859
00:39:13.655 --> 00:39:15.195
<00:39:13.655>of <00:39:14.117>promises <00:39:14.579>and <00:39:15.041>generators.

860
00:39:15.815 --> 00:39:19.555
<00:39:15.815>So <00:39:15.931>what <00:39:16.048>if <00:39:16.165>we <00:39:16.281>have <00:39:16.398>an <00:39:16.515>async <00:39:16.631>function <00:39:16.748>but <00:39:16.865>we <00:39:16.981>don't <00:39:17.098>await <00:39:17.215>it?

861
00:39:20.345 --> 00:39:23.435
<00:39:20.345>What <00:39:20.578>is <00:39:20.811>res? <00:39:21.044>Well, <00:39:21.278>it's <00:39:21.511>a <00:39:21.745>promise.

862
00:39:24.015 --> 00:39:26.275
<00:39:24.015>We <00:39:24.214>know <00:39:24.415>how <00:39:24.615>to <00:39:24.815>dot <00:39:25.015>then <00:39:25.214>a <00:39:25.415>promise.

863
00:39:26.655 --> 00:39:28.275
<00:39:26.655>So <00:39:26.888>if <00:39:27.121>we <00:39:27.355>have <00:39:27.588>a <00:39:27.821>new <00:39:28.055>function

864
00:39:28.275 --> 00:39:31.475
<00:39:28.275>and <00:39:28.391>we <00:39:28.508>need <00:39:28.625>to <00:39:28.741>call <00:39:28.858>it <00:39:28.975>from <00:39:29.091>Legacy <00:39:29.208>Code, <00:39:29.325>we <00:39:29.441>just <00:39:29.558>dot <00:39:29.675>then

865
00:39:31.815 --> 00:39:33.635
<00:39:31.815>and <00:39:32.048>we've <00:39:32.281>got <00:39:32.515>our <00:39:32.748>content <00:39:32.981>into <00:39:33.215>place.

866
00:39:34.275 --> 00:39:37.735
<00:39:34.275>Excellent. <00:39:34.430>Can <00:39:34.586>we <00:39:34.741>go <00:39:34.897>the <00:39:35.052>other <00:39:35.208>direction? <00:39:35.363>We <00:39:35.519>definitely <00:39:35.675>can.

867
00:39:38.075 --> 00:39:40.055
<00:39:38.075>Here's <00:39:38.308>a <00:39:38.541>promise. <00:39:38.774>And <00:39:39.008>what <00:39:39.241>is <00:39:39.475>res?

868
00:39:40.325 --> 00:39:43.375
<00:39:40.325>Well, <00:39:40.480>it's <00:39:40.636>a <00:39:40.791>promise <00:39:40.947>and <00:39:41.102>we <00:39:41.258>can <00:39:41.413>await <00:39:41.569>a <00:39:41.725>promise.

869
00:39:43.395 --> 00:39:44.855
<00:39:43.395>That's <00:39:43.657>how <00:39:43.920>Async <00:39:44.183>can <00:39:44.446>Await <00:39:44.709>works.

870
00:39:45.195 --> 00:39:46.695
<00:39:45.195>So <00:39:45.532>let's <00:39:45.870>await <00:39:46.207>that <00:39:46.545>promise

871
00:39:47.035 --> 00:39:50.055
<00:39:47.035>and <00:39:47.190>as <00:39:47.346>we're <00:39:47.501>writing <00:39:47.657>new <00:39:47.812>code, <00:39:47.968>calling <00:39:48.123>into <00:39:48.279>Legacy <00:39:48.435>code,

872
00:39:50.355 --> 00:39:52.215
<00:39:50.355>we <00:39:50.555>can <00:39:50.755>use <00:39:50.955>Async <00:39:51.155>and <00:39:51.355>Await <00:39:51.555>right <00:39:51.755>away.

873
00:39:53.535 --> 00:39:54.545
<00:39:53.535>That <00:39:53.989>is <00:39:54.444>excellent.

874
00:39:54.995 --> 00:39:57.625
<00:39:54.995>Async <00:39:55.170>and <00:39:55.345>Await <00:39:55.520>has <00:39:55.694>a <00:39:55.870>really <00:39:56.045>great <00:39:56.220>interop <00:39:56.395>story

875
00:39:57.625 --> 00:40:00.785
<00:39:57.625>with <00:39:57.800>promises <00:39:57.975>and <00:39:58.150>allows <00:39:58.325>us <00:39:58.500>to <00:39:58.675>await <00:39:58.850>a <00:39:59.025>promise

876
00:40:01.325 --> 00:40:03.385
<00:40:01.325>or <00:40:01.605>dot <00:40:01.884>thin <00:40:02.165>an <00:40:02.444>async <00:40:02.725>method.

877
00:40:04.115 --> 00:40:05.865
<00:40:04.115>Let's <00:40:04.290>take <00:40:04.464>that <00:40:04.640>for <00:40:04.814>a <00:40:04.990>spin <00:40:05.165>as <00:40:05.339>we <00:40:05.515>want

878
00:40:05.865 --> 00:40:07.425
<00:40:05.865>to <00:40:06.145>run <00:40:06.424>many <00:40:06.705>things <00:40:06.984>in <00:40:07.265>parallel.

879
00:40:07.685 --> 00:40:09.905
<00:40:07.685>Now, <00:40:07.918>JavaScript <00:40:08.151>is <00:40:08.384>still <00:40:08.618>thing <00:40:08.851>single <00:40:09.085>threaded,

880
00:40:10.045 --> 00:40:12.745
<00:40:10.045>but <00:40:10.185>we're <00:40:10.325>gonna <00:40:10.465>set <00:40:10.605>these <00:40:10.745>in <00:40:10.885>the <00:40:11.025>web <00:40:11.165>API <00:40:11.305>callback <00:40:11.445>queue.

881
00:40:13.125 --> 00:40:14.185
<00:40:13.125>And <00:40:13.443>once <00:40:13.761>they're <00:40:14.078>done,

882
00:40:14.215 --> 00:40:15.985
<00:40:14.215>then <00:40:14.448>they'll <00:40:14.681>go <00:40:14.915>into <00:40:15.148>our <00:40:15.381>callback <00:40:15.615>stack

883
00:40:16.245 --> 00:40:17.945
<00:40:16.245>and <00:40:16.478>then <00:40:16.711>finally <00:40:16.944>into <00:40:17.178>our <00:40:17.411>GUI <00:40:17.645>thread.

884
00:40:19.025 --> 00:40:20.525
<00:40:19.025>So <00:40:19.295>we <00:40:19.565>have <00:40:19.835>this <00:40:20.105>async <00:40:20.375>function

885
00:40:20.665 --> 00:40:22.005
<00:40:20.665>and <00:40:20.866>we're <00:40:21.067>gonna <00:40:21.268>call <00:40:21.469>each <00:40:21.670>of <00:40:21.871>them,

886
00:40:22.185 --> 00:40:23.765
<00:40:22.185>but <00:40:22.418>we're <00:40:22.651>not <00:40:22.884>going <00:40:23.118>to <00:40:23.351>await <00:40:23.585>them.

887
00:40:24.825 --> 00:40:28.165
<00:40:24.825>Now, <00:40:24.964>promise <00:40:25.105>Dot <00:40:25.245>all <00:40:25.384>knows <00:40:25.524>how <00:40:25.665>to <00:40:25.805>wait <00:40:25.944>for <00:40:26.085>an <00:40:26.225>array

888
00:40:28.165 --> 00:40:30.565
<00:40:28.165>of <00:40:28.340>promises <00:40:28.515>and <00:40:28.690>give <00:40:28.865>us <00:40:29.040>an <00:40:29.215>array <00:40:29.390>of <00:40:29.565>results.

889
00:40:31.225 --> 00:40:33.285
<00:40:31.225>So <00:40:31.400>now <00:40:31.575>that <00:40:31.750>we've <00:40:31.924>got <00:40:32.100>this <00:40:32.275>array <00:40:32.450>of <00:40:32.625>results,

890
00:40:33.425 --> 00:40:37.925
<00:40:33.425>we <00:40:33.552>can <00:40:33.679>return <00:40:33.806>them <00:40:33.934>and <00:40:34.061>if <00:40:34.188>any <00:40:34.315>of <00:40:34.443>these <00:40:34.570>things, <00:40:34.697>uh, <00:40:34.825>error,

891
00:40:38.195 --> 00:40:39.325
<00:40:38.195>then <00:40:38.449>we'll <00:40:38.703>hit <00:40:38.957>our <00:40:39.212>catch

892
00:40:39.425 --> 00:40:41.245
<00:40:39.425>and <00:40:39.600>we <00:40:39.775>can <00:40:39.950>handle <00:40:40.125>our <00:40:40.300>error <00:40:40.475>nicely <00:40:40.650>as <00:40:40.825>well.

893
00:40:42.415 --> 00:40:44.595
<00:40:42.415>Now, <00:40:42.615>we <00:40:42.815>didn't <00:40:43.015>await <00:40:43.215>each <00:40:43.415>of <00:40:43.615>these <00:40:43.815>promises,

894
00:40:44.735 --> 00:40:47.835
<00:40:44.735>but <00:40:44.910>we <00:40:45.085>used <00:40:45.260>Promise <00:40:45.435>dot <00:40:45.610>all <00:40:45.785>to <00:40:45.960>be <00:40:46.135>able

895
00:40:47.835 --> 00:40:49.915
<00:40:47.835>to <00:40:48.010>get <00:40:48.185>at <00:40:48.360>those <00:40:48.535>results <00:40:48.710>so <00:40:48.885>that <00:40:49.060>all <00:40:49.235>three

896
00:40:49.915 --> 00:40:53.115
<00:40:49.915>of <00:40:50.090>those <00:40:50.265>web <00:40:50.440>requests <00:40:50.615>will <00:40:50.790>happen <00:40:50.965>in <00:40:51.140>in <00:40:51.315>parallel.

897
00:40:53.335 --> 00:40:57.825
<00:40:53.335>That's <00:40:53.685>excellent. <00:40:54.035>JavaScript <00:40:54.385>not <00:40:54.735>bad

898
00:40:57.845 --> 00:41:00.425
<00:40:57.845>for <00:40:58.044>a <00:40:58.245>10 <00:40:58.444>day <00:40:58.645>project <00:40:58.845>25 <00:40:59.044>years <00:40:59.245>ago.

899
00:41:01.045 --> 00:41:03.505
<00:41:01.045>The <00:41:01.200>code <00:41:01.356>I <00:41:01.511>wrote <00:41:01.667>25 <00:41:01.822>years <00:41:01.978>ago <00:41:02.133>isn't <00:41:02.289>getting <00:41:02.445>executed

900
00:41:03.505 --> 00:41:05.545
<00:41:03.505>anymore, <00:41:03.971>but <00:41:04.438>this <00:41:04.905>code

901
00:41:05.705 --> 00:41:09.625
<00:41:05.705>that <00:41:05.880>Brendan <00:41:06.055>created <00:41:06.230>25 <00:41:06.404>years <00:41:06.580>ago <00:41:06.755>is <00:41:06.930>that <00:41:07.105>thing

902
00:41:09.625 --> 00:41:11.225
<00:41:09.625>that <00:41:09.975>has <00:41:10.325>created <00:41:10.675>this <00:41:11.025>conference

903
00:41:11.485 --> 00:41:14.065
<00:41:11.485>and <00:41:11.660>allows <00:41:11.835>us <00:41:12.010>to <00:41:12.185>do <00:41:12.360>some <00:41:12.535>really <00:41:12.710>excellent <00:41:12.885>things.

904
00:41:14.605 --> 00:41:15.665
<00:41:14.605>He <00:41:14.843>did <00:41:15.082>a <00:41:15.320>great <00:41:15.559>job.

905
00:41:17.705 --> 00:41:20.405
<00:41:17.705>Thanks <00:41:17.880>for <00:41:18.055>joining <00:41:18.230>us <00:41:18.404>here <00:41:18.580>at <00:41:18.755>JavaScript <00:41:18.930>World <00:41:19.105>Conference.

906
00:41:20.665 --> 00:41:22.805
<00:41:20.665>Uh, <00:41:20.840>for <00:41:21.015>those <00:41:21.190>of <00:41:21.365>you <00:41:21.540>watching <00:41:21.715>this <00:41:21.890>video <00:41:22.065>later,

907
00:41:22.985 --> 00:41:25.285
<00:41:22.985>hit <00:41:23.160>me <00:41:23.335>up <00:41:23.510>on <00:41:23.685>Twitter <00:41:23.860>at <00:41:24.035>Rob <00:41:24.210>underscore <00:41:24.385>Rich

908
00:41:25.365 --> 00:41:26.685
<00:41:25.365>and <00:41:25.662>let's <00:41:25.959>continue <00:41:26.256>the <00:41:26.553>conversation.

909
00:41:27.145 --> 00:41:29.725
<00:41:27.145>You <00:41:27.300>can <00:41:27.456>grab <00:41:27.611>the <00:41:27.767>slides <00:41:27.922>right <00:41:28.078>now <00:41:28.233>on <00:41:28.389>rob <00:41:28.545>rich.org.

910
00:41:30.065 --> 00:41:32.005
<00:41:30.065>For <00:41:30.220>those <00:41:30.376>of <00:41:30.531>us <00:41:30.687>who <00:41:30.842>are <00:41:30.998>here <00:41:31.153>live <00:41:31.309>in <00:41:31.465>the

911
00:41:32.005 --> 00:41:33.745
<00:41:32.005>event, <00:41:32.355>what <00:41:32.705>are <00:41:33.055>your <00:41:33.405>questions?

912
00:41:33.935 --> 00:41:34.935
<00:41:33.935>What <00:41:34.235>are <00:41:34.535>your <00:41:34.835>thoughts?

913
00:41:40.905 --> 00:41:42.685
<00:41:40.905>Thanks <00:41:41.255>for <00:41:41.605>your <00:41:41.955>session, <00:41:42.305>Rob.

914
00:41:42.785 --> 00:41:46.645
<00:41:42.785>Really, <00:41:42.940>some, <00:41:43.096>um, <00:41:43.251>some <00:41:43.407>moments <00:41:43.562>are <00:41:43.718>quite, <00:41:43.873>uh, <00:41:44.029>mind <00:41:44.185>blowing

915
00:41:46.865 --> 00:41:51.645
<00:41:46.865>and, <00:41:47.020>um, <00:41:47.176>maybe, <00:41:47.331>uh, <00:41:47.487>you <00:41:47.642>have <00:41:47.798>to <00:41:47.953>rewatch, <00:41:48.109>uh, <00:41:48.265>your,

916
00:41:51.835 --> 00:41:52.925
<00:41:51.835>your <00:41:52.080>session <00:41:52.325>couple <00:41:52.570>of <00:41:52.816>times

917
00:41:53.025 --> 00:41:55.485
<00:41:53.025>to <00:41:53.375>understand <00:41:53.725>everything, <00:41:54.075>uh, <00:41:54.425>completely.

918
00:41:55.485 --> 00:41:57.925
<00:41:55.485>This <00:41:55.640>is <00:41:55.796>my <00:41:55.951>recommendation <00:41:56.107>for <00:41:56.262>you <00:41:56.418>folks, <00:41:56.573>for <00:41:56.729>all <00:41:56.885>attendees

919
00:41:57.925 --> 00:42:01.765
<00:41:57.925>who <00:41:58.125>want <00:41:58.325>to <00:41:58.525>really <00:41:58.725>understand <00:41:58.925>how <00:41:59.125>JavaScript <00:41:59.325>works

920
00:42:01.905 --> 00:42:06.885
<00:42:01.905>and, <00:42:02.045>uh, <00:42:02.185>not <00:42:02.325>to, <00:42:02.465>um, <00:42:02.605>you <00:42:02.745>know, <00:42:02.885>start <00:42:03.025>hating <00:42:03.165>this, <00:42:03.305>uh,

921
00:42:07.145 --> 00:42:11.485
<00:42:07.145>too, <00:42:07.320>too <00:42:07.495>fast <00:42:07.670>without, <00:42:07.845>uh, <00:42:08.020>without <00:42:08.195>understanding <00:42:08.370>all <00:42:08.545>this,

922
00:42:11.605 --> 00:42:12.685
<00:42:11.605>uh, <00:42:12.091>beautiful <00:42:12.577>parts

923
00:42:12.705 --> 00:42:15.405
<00:42:12.705>and, <00:42:12.938>uh, <00:42:13.171>maybe <00:42:13.404>let's <00:42:13.638>say <00:42:13.871>Nonobvious <00:42:14.105>parts.

924
00:42:15.905 --> 00:42:20.405
<00:42:15.905>So <00:42:16.045>we <00:42:16.185>have <00:42:16.325>a <00:42:16.465>very <00:42:16.605>active <00:42:16.745>discussion <00:42:16.885>in, <00:42:17.025>uh, <00:42:17.165>live <00:42:17.305>chat.

925
00:42:21.385 --> 00:42:24.965
<00:42:21.385>And, <00:42:21.560>um, <00:42:21.735>one, <00:42:21.910>one <00:42:22.085>only <00:42:22.260>one <00:42:22.435>question <00:42:22.610>so <00:42:22.785>far

926
00:42:24.965 --> 00:42:26.725
<00:42:24.965>because <00:42:25.165>I, <00:42:25.365>I <00:42:25.565>believe, <00:42:25.765>uh, <00:42:25.965>people <00:42:26.165>still, <00:42:26.365>uh,

927
00:42:26.945 --> 00:42:28.325
<00:42:26.945>digest <00:42:27.566>this <00:42:28.187>information.

928
00:42:29.105 --> 00:42:33.285
<00:42:29.105>So <00:42:29.338>this <00:42:29.571>using <00:42:29.805>Arrow <00:42:30.038>functions <00:42:30.271>actually <00:42:30.505>better.

929
00:42:34.875 --> 00:42:36.565
<00:42:34.875>Very <00:42:35.108>general <00:42:35.341>question, <00:42:35.575>what <00:42:35.808>do <00:42:36.041>you <00:42:36.275>think?

930
00:42:36.905 --> 00:42:40.725
<00:42:36.905>Ooh, <00:42:37.105>yeah. <00:42:37.305>Is <00:42:37.505>using <00:42:37.705>Arrow <00:42:37.905>functions <00:42:38.105>actually <00:42:38.305>better?

931
00:42:40.815 --> 00:42:43.725
<00:42:40.815>Great <00:42:41.095>question. <00:42:41.375>It <00:42:41.655>is <00:42:41.935>fewer <00:42:42.215>characters,

932
00:42:43.745 --> 00:42:44.885
<00:42:43.745>and <00:42:43.891>so <00:42:44.038>in <00:42:44.184>that <00:42:44.331>case <00:42:44.477>it <00:42:44.624>is <00:42:44.771>better.

933
00:42:45.745 --> 00:42:49.045
<00:42:45.745>We <00:42:45.861>did <00:42:45.978>see <00:42:46.095>how <00:42:46.211>we <00:42:46.328>could <00:42:46.444>use <00:42:46.561>it <00:42:46.678>to <00:42:46.795>capture <00:42:46.911>the <00:42:47.028>current <00:42:47.145>scope

934
00:42:49.345 --> 00:42:51.285
<00:42:49.345>and <00:42:49.544>that <00:42:49.745>in <00:42:49.944>this <00:42:50.145>case <00:42:50.345>made <00:42:50.544>it <00:42:50.745>better

935
00:42:51.285 --> 00:42:52.805
<00:42:51.285>because <00:42:51.513>we <00:42:51.741>wanted <00:42:51.969>to <00:42:52.196>use <00:42:52.424>that <00:42:52.653>feature.

936
00:42:53.745 --> 00:42:55.245
<00:42:53.745>But <00:42:53.970>is <00:42:54.194>it <00:42:54.420>better <00:42:54.645>in <00:42:54.870>all <00:42:55.095>cases?

937
00:42:55.825 --> 00:42:57.125
<00:42:55.825>Uh, <00:42:56.214>it <00:42:56.605>definitely <00:42:56.995>isn't

938
00:42:57.315 --> 00:42:59.205
<00:42:57.315>because <00:42:57.595>it's <00:42:57.875>gonna <00:42:58.155>override <00:42:58.435>the <00:42:58.715>scope.

939
00:42:59.505 --> 00:43:01.125
<00:42:59.505>Um, <00:42:59.785>there <00:43:00.065>are <00:43:00.345>places <00:43:00.625>where <00:43:00.905>Arrow

940
00:43:01.485 --> 00:43:02.645
<00:43:01.485>functions <00:43:01.746>can <00:43:02.007>really <00:43:02.268>cause <00:43:02.529>damage.

941
00:43:03.225 --> 00:43:06.605
<00:43:03.225>Now, <00:43:03.365>if <00:43:03.505>you're <00:43:03.645>doing <00:43:03.785>MOCA <00:43:03.924>tests, <00:43:04.065>moca <00:43:04.205>has <00:43:04.345>the <00:43:04.485>ability <00:43:04.625>to

942
00:43:07.165 --> 00:43:08.325
<00:43:07.165>configure <00:43:08.209>timeouts

943
00:43:08.325 --> 00:43:11.245
<00:43:08.325>and <00:43:08.524>other <00:43:08.725>things <00:43:08.924>by <00:43:09.125>setting <00:43:09.325>this <00:43:09.524>dot <00:43:09.725>content.

944
00:43:11.825 --> 00:43:14.365
<00:43:11.825>And <00:43:11.980>so <00:43:12.136>if <00:43:12.291>you <00:43:12.447>arrow <00:43:12.602>function <00:43:12.758>all <00:43:12.913>of <00:43:13.069>your <00:43:13.225>tests,

945
00:43:14.665 --> 00:43:16.845
<00:43:14.665>you <00:43:14.865>lose <00:43:15.065>the <00:43:15.265>ability <00:43:15.465>to <00:43:15.665>set <00:43:15.865>those <00:43:16.065>values.

946
00:43:17.425 --> 00:43:20.205
<00:43:17.425>That's <00:43:17.625>a <00:43:17.825>spot <00:43:18.025>where <00:43:18.225>you're <00:43:18.425>actually <00:43:18.625>doing <00:43:18.825>damage

947
00:43:20.265 --> 00:43:21.445
<00:43:20.265>by <00:43:20.619>using <00:43:20.973>Arrow <00:43:21.327>functions.

948
00:43:21.705 --> 00:43:23.605
<00:43:21.705>Now <00:43:21.904>Arrow <00:43:22.105>functions <00:43:22.305>are <00:43:22.505>definitely <00:43:22.705>a <00:43:22.904>helpful <00:43:23.105>tool,

949
00:43:23.865 --> 00:43:25.725
<00:43:23.865>so <00:43:24.145>don't <00:43:24.424>just <00:43:24.705>discard <00:43:24.984>them <00:43:25.265>completely,

950
00:43:26.305 --> 00:43:28.765
<00:43:26.305>but <00:43:26.480>they're <00:43:26.654>not <00:43:26.830>the <00:43:27.004>perfect <00:43:27.180>answer <00:43:27.355>to <00:43:27.529>every <00:43:27.705>solution.

951
00:43:29.035 --> 00:43:30.885
<00:43:29.035>They're <00:43:29.268>a <00:43:29.501>great <00:43:29.734>tool <00:43:29.968>when <00:43:30.201>they're <00:43:30.435>useful,

952
00:43:31.185 --> 00:43:34.085
<00:43:31.185>and <00:43:31.325>that's <00:43:31.465>part <00:43:31.605>of <00:43:31.745>why <00:43:31.884>we <00:43:32.025>spent <00:43:32.165>so <00:43:32.305>much <00:43:32.445>time <00:43:32.585>discovering

953
00:43:34.085 --> 00:43:36.445
<00:43:34.085>how <00:43:34.240>they <00:43:34.396>work <00:43:34.551>so <00:43:34.707>that <00:43:34.862>you <00:43:35.018>can <00:43:35.173>use <00:43:35.329>them <00:43:35.485>correctly.

954
00:43:37.995 --> 00:43:39.005
<00:43:37.995>Fair <00:43:38.298>enough, <00:43:38.601>fair <00:43:38.904>enough.

955
00:43:39.185 --> 00:43:44.005
<00:43:39.185>No <00:43:39.301>one <00:43:39.418>size <00:43:39.535>fits <00:43:39.651>all, <00:43:39.768>uh, <00:43:39.884>be <00:43:40.001>be <00:43:40.118>be <00:43:40.235>be <00:43:40.351>mindful <00:43:40.468>when <00:43:40.585>you

956
00:43:44.665 --> 00:43:47.045
<00:43:44.665>use <00:43:44.945>this <00:43:45.225>or <00:43:45.505>that, <00:43:45.785>uh, <00:43:46.065>uh,

957
00:43:47.235 --> 00:43:49.045
<00:43:47.235>mechanism <00:43:47.585>in <00:43:47.935>your <00:43:48.285>programmatic <00:43:48.635>language.

958
00:43:49.545 --> 00:43:51.685
<00:43:49.545>Uh, <00:43:49.778>exactly. <00:43:50.011>The <00:43:50.245>next <00:43:50.478>question <00:43:50.711>is, <00:43:50.945>um,

959
00:43:52.385 --> 00:43:55.165
<00:43:52.385>is <00:43:52.618>there <00:43:52.851>anyone <00:43:53.085>thinking <00:43:53.318>about <00:43:53.551>node <00:43:53.785>js

960
00:43:55.225 --> 00:43:57.405
<00:43:55.225>to <00:43:55.691>execute <00:43:56.158>a <00:43:56.625>multithread

961
00:43:59.545 --> 00:44:00.545
<00:43:59.545>Ooh <00:43:59.995>yes. <00:44:00.445>Multithreaded

962
00:44:00.545 --> 00:44:03.445
<00:44:00.545>node? <00:44:00.895>That <00:44:01.245>is <00:44:01.595>really <00:44:01.945>cool.

963
00:44:04.245 --> 00:44:05.965
<00:44:04.245>The <00:44:04.595>really <00:44:04.944>low <00:44:05.295>tech <00:44:05.645>solution

964
00:44:05.985 --> 00:44:10.485
<00:44:05.985>to <00:44:06.160>execute <00:44:06.335>multithreaded <00:44:06.510>node <00:44:06.685>is <00:44:06.860>to <00:44:07.035>start <00:44:07.210>multiple <00:44:07.385>instances

965
00:44:10.585 --> 00:44:12.965
<00:44:10.585>and <00:44:10.740>maybe <00:44:10.896>put <00:44:11.051>them <00:44:11.207>behind <00:44:11.362>a <00:44:11.518>load <00:44:11.673>balancer <00:44:11.829>like <00:44:11.985>N

966
00:44:12.965 --> 00:44:14.205
<00:44:12.965>Engine <00:44:13.337>X <00:44:13.709>or <00:44:14.081>Kubernetes.

967
00:44:14.425 --> 00:44:17.845
<00:44:14.425>And <00:44:14.580>at <00:44:14.736>that <00:44:14.891>point <00:44:15.047>then <00:44:15.202>you <00:44:15.358>do <00:44:15.513>have <00:44:15.669>multithreaded <00:44:15.825>node.

968
00:44:18.305 --> 00:44:20.645
<00:44:18.305>Now <00:44:18.538>there <00:44:18.771>are <00:44:19.004>mechanisms <00:44:19.238>for <00:44:19.471>doing <00:44:19.705>multithreading

969
00:44:20.705 --> 00:44:21.805
<00:44:20.705>inside <00:44:21.200>of <00:44:21.694>JavaScript.

970
00:44:21.905 --> 00:44:24.605
<00:44:21.905>We <00:44:22.185>have <00:44:22.465>web <00:44:22.745>workers <00:44:23.025>inside <00:44:23.305>browsers.

971
00:44:24.965 --> 00:44:28.085
<00:44:24.965>I <00:44:25.105>believe <00:44:25.245>Node <00:44:25.385>now <00:44:25.525>has <00:44:25.665>an <00:44:25.805>implementation <00:44:25.945>of <00:44:26.085>WebWork <00:44:26.225>as <00:44:26.365>well.

972
00:44:28.545 --> 00:44:30.565
<00:44:28.545>You <00:44:28.745>could <00:44:28.945>also <00:44:29.145>shell <00:44:29.345>out <00:44:29.545>into <00:44:29.745>other <00:44:29.945>spots

973
00:44:30.575 --> 00:44:33.925
<00:44:30.575>where <00:44:30.750>maybe <00:44:30.924>you <00:44:31.100>do <00:44:31.274>a <00:44:31.450>web <00:44:31.625>request <00:44:31.799>into <00:44:31.975>Python

974
00:44:34.265 --> 00:44:37.485
<00:44:34.265>or <00:44:34.404>C <00:44:34.545>to <00:44:34.685>be <00:44:34.825>able <00:44:34.964>to <00:44:35.105>get <00:44:35.245>at <00:44:35.384>those <00:44:35.525>multi-threaded <00:44:35.665>capabilities.

975
00:44:38.095 --> 00:44:40.765
<00:44:38.095>JavaScript <00:44:38.444>itself <00:44:38.794>is <00:44:39.145>not <00:44:39.495>multi-threaded,

976
00:44:40.945 --> 00:44:42.885
<00:44:40.945>and <00:44:41.120>so <00:44:41.295>the <00:44:41.470>way <00:44:41.645>you <00:44:41.820>would <00:44:41.995>do <00:44:42.170>that <00:44:42.345>is

977
00:44:42.905 --> 00:44:44.605
<00:44:42.905>to <00:44:43.371>create <00:44:43.838>multiple <00:44:44.305>instances.

978
00:44:45.305 --> 00:44:47.405
<00:44:45.305>Now, <00:44:45.460>the <00:44:45.616>beauty <00:44:45.771>of <00:44:45.927>that <00:44:46.082>is <00:44:46.238>that <00:44:46.393>we <00:44:46.549>don't <00:44:46.705>need

979
00:44:47.405 --> 00:44:50.525
<00:44:47.405>to <00:44:47.605>worry <00:44:47.805>about <00:44:48.005>race <00:44:48.205>conditions <00:44:48.405>and <00:44:48.605>locking <00:44:48.805>variables.

980
00:44:50.905 --> 00:44:53.645
<00:44:50.905>So <00:44:51.255>JavaScript <00:44:51.605>is <00:44:51.955>significantly <00:44:52.305>simpler

981
00:44:53.645 --> 00:44:56.045
<00:44:53.645>because <00:44:53.995>it's <00:44:54.345>single <00:44:54.695>threaded, <00:44:55.045>but

982
00:44:56.045 --> 00:44:58.445
<00:44:56.045>because <00:44:56.200>it's <00:44:56.356>single <00:44:56.511>threaded, <00:44:56.667>we <00:44:56.822>do <00:44:56.978>need <00:44:57.133>to <00:44:57.289>be <00:44:57.445>careful

983
00:44:58.585 --> 00:45:00.485
<00:44:58.585>to <00:44:58.818>yield <00:44:59.051>the <00:44:59.285>thread <00:44:59.518>if <00:44:59.751>we're <00:44:59.985>about

984
00:45:00.485 --> 00:45:02.045
<00:45:00.485>to <00:45:00.718>do <00:45:00.951>a <00:45:01.185>really <00:45:01.418>long <00:45:01.651>running <00:45:01.885>task.

985
00:45:02.385 --> 00:45:06.245
<00:45:02.385>To <00:45:02.512>that <00:45:02.639>end, <00:45:02.766>maybe <00:45:02.894>you <00:45:03.021>need <00:45:03.148>to <00:45:03.275>fan <00:45:03.403>out <00:45:03.530>your <00:45:03.657>content <00:45:03.785>across,

986
00:45:06.665 --> 00:45:09.045
<00:45:06.665>uh, <00:45:06.898>a <00:45:07.131>series <00:45:07.365>of <00:45:07.598>functions <00:45:07.831>like <00:45:08.065>Lambda

987
00:45:09.065 --> 00:45:11.205
<00:45:09.065>or <00:45:09.345>Azure <00:45:09.625>functions <00:45:09.905>to <00:45:10.185>be <00:45:10.465>able

988
00:45:11.205 --> 00:45:14.285
<00:45:11.205>to <00:45:11.404>have <00:45:11.605>each <00:45:11.805>thread <00:45:12.005>accomplish <00:45:12.205>a <00:45:12.404>particular <00:45:12.605>task

989
00:45:14.545 --> 00:45:17.125
<00:45:14.545>and <00:45:14.700>not <00:45:14.856>need <00:45:15.011>to <00:45:15.167>worry <00:45:15.322>about <00:45:15.478>competing <00:45:15.633>with <00:45:15.789>other <00:45:15.945>threads.

990
00:45:19.685 --> 00:45:22.505
<00:45:19.685>Yes, <00:45:19.884>thanks <00:45:20.085>for <00:45:20.285>for, <00:45:20.485>for <00:45:20.685>this <00:45:20.884>detailed <00:45:21.085>explanation.

991
00:45:23.005 --> 00:45:27.385
<00:45:23.005>Um, <00:45:23.238>there <00:45:23.471>are <00:45:23.705>couple <00:45:23.938>more <00:45:24.171>questions, <00:45:24.405>um,

992
00:45:27.805 --> 00:45:32.345
<00:45:27.805>or <00:45:27.912>please <00:45:28.020>go, <00:45:28.128>um, <00:45:28.235>to <00:45:28.343>a <00:45:28.451>q <00:45:28.558>and <00:45:28.666>a <00:45:28.774>session <00:45:28.881>and, <00:45:28.989>um, <00:45:29.097>answer <00:45:29.205>this,

993
00:45:32.565 --> 00:45:34.945
<00:45:32.565>but <00:45:32.798>let's, <00:45:33.031>um, <00:45:33.265>wrap <00:45:33.498>our <00:45:33.731>session <00:45:33.965>up

994
00:45:35.125 --> 00:45:39.385
<00:45:35.125>and <00:45:35.232>uh, <00:45:35.340>I <00:45:35.448>just <00:45:35.555>want <00:45:35.663>to, <00:45:35.771>uh, <00:45:35.878>read, <00:45:35.986>um, <00:45:36.094>it's <00:45:36.201>in <00:45:36.309>q <00:45:36.417>and <00:45:36.525>a,

995
00:45:39.385 --> 00:45:40.545
<00:45:39.385>but <00:45:39.593>it's <00:45:39.802>not <00:45:40.011>actually <00:45:40.220>a <00:45:40.429>question.

996
00:45:40.545 --> 00:45:43.585
<00:45:40.545>This <00:45:40.720>is <00:45:40.895>feedback. <00:45:41.070>Simon <00:45:41.245>is, <00:45:41.420>uh, <00:45:41.595>saying <00:45:41.770>thank <00:45:41.945>you

997
00:45:43.645 --> 00:45:46.905
<00:45:43.645>for <00:45:43.878>this <00:45:44.111>very <00:45:44.345>entertaining <00:45:44.578>and <00:45:44.811>informative <00:45:45.045>talk.

998
00:45:47.465 --> 00:45:50.465
<00:45:47.465>I <00:45:47.620>second <00:45:47.776>what <00:45:47.931>Simon <00:45:48.087>says. <00:45:48.242>Thank <00:45:48.398>you <00:45:48.553>very <00:45:48.709>much, <00:45:48.865>Rob.

999
00:45:50.485 --> 00:45:51.865
<00:45:50.485>It <00:45:50.692>was <00:45:50.899>great. <00:45:51.106>Pleasure <00:45:51.313>to <00:45:51.520>have <00:45:51.727>you.

1000
00:45:53.635 --> 00:45:56.165
<00:45:53.635>Most <00:45:53.775>definitely. <00:45:53.915>I'm <00:45:54.055>so <00:45:54.195>glad <00:45:54.335>that <00:45:54.475>I <00:45:54.615>got <00:45:54.755>to <00:45:54.895>share <00:45:55.035>this

1001
00:45:56.165 --> 00:45:57.925
<00:45:56.165>with <00:45:56.398>you <00:45:56.631>and <00:45:56.865>let's <00:45:57.098>continue <00:45:57.331>the <00:45:57.565>conversation.

1002
00:45:57.925 --> 00:45:59.085
<00:45:57.925>Thanks <00:45:58.186>for <00:45:58.447>the <00:45:58.708>kudos, <00:45:58.969>Simon.

1003
00:45:59.435 --> 00:46:02.045
<00:45:59.435>Grab <00:45:59.575>me <00:45:59.715>on <00:45:59.855>Twitter <00:45:59.995>at <00:46:00.134>Rob <00:46:00.275>Rich <00:46:00.415>and <00:46:00.555>let's <00:46:00.695>continue <00:46:00.835>on.

1004
00:46:02.625 --> 00:46:03.365
<00:46:02.625>Thanks <00:46:03.290>everyone.