forked from aaronfrost/es6-femasters-slides
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spread.html
174 lines (151 loc) · 4.7 KB
/
spread.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<!--
Google IO 2012/2013 HTML5 Slide Template
Authors: Eric Bidelman <ebidel@gmail.com>
Luke Mahé <lukem@google.com>
URL: https://code.google.com/p/io-2012-slides
-->
<!DOCTYPE html>
<html>
<head>
<title>Spread Operator</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<!--<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">-->
<!--<meta name="viewport" content="width=device-width, initial-scale=1.0">-->
<!--This one seems to work all the time, but really small on ipad-->
<!--<meta name="viewport" content="initial-scale=0.4">-->
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" media="all" href="theme/css/default.css">
<link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="theme/css/phone.css">
<base target="_blank"> <!-- This amazingness opens all links in a new tab. -->
<script data-main="js/slides" src="js/require-1.0.8.min.js"></script>
</head>
<body style="opacity: 0">
<slides class="layout-widescreen">
<slide class="title-slide segue nobackground">
<aside class="gdbar"><img src="images/es6.png"></aside>
<!-- The content of this hgroup is replaced programmatically through the slide_config.json. -->
<hgroup class="auto-fadein">
<h1 data-config-title style="display: none;"><!-- populated from slide_config.json --></h1>
<h2 data-config-subtitle style="display: none;"><!-- populated from slide_config.json --></h2>
<p data-config-presenter style="display: none;"><!-- populated from slide_config.json --></p>
<h1>Spread Operator</h1>
<p data-config-presenter><!-- populated from slide_config.json --></p>
</hgroup>
</slide>
<slide>
<hgroup>
<h2>Spread Operator</h2>
</hgroup>
<article>
<h2>Quick Lesson</h2>
</article>
</slide>
<slide>
<hgroup>
<h2>Spread Operator</h2>
</hgroup>
<article>
<p>
<h4><b>'...'</b> before an array</h4>
</p>
<pre class="prettyprint" data-lang="javascript">
var nums = [1, 2, 3];
<b>log(nums); //logs [1, 2, 3]</b>
<b>log(...nums); //logs 1, 2, 3</b>
</pre>
</article>
</slide>
<slide>
<hgroup>
<h2>Spread Operator</h2>
</hgroup>
<article>
<pre class="prettyprint" data-lang="javascript">
function returnTwo(a,b){
return [b,a]; <b>//Flips 'a' and 'b'</b>
}
var a = [1, 2, 3];
var b = <b>returnTwo(a[0], a[1]);</b> // [2, 1]
var c = <b>returnTwo(...a);</b> // [2, 1]
</pre>
</article>
</slide>
<slide>
<hgroup>
<h2>Spread Operator</h2>
</hgroup>
<article>
<h2>What can I do with Spreading?</h2>
</article>
</slide>
<slide>
<hgroup>
<h2>Spread Operator</h2>
</hgroup>
<article>
<p>
<h4>Combine Arrays</h4>
</p>
<pre class="prettyprint" data-lang="javascript">
let nums = [1, 2, 3];
let abcs = ['a', 'b', 'c'];
let alphanum = <b>[ ...nums, ...abcs ]; //[1, 2, 3, 'a', 'b', 'c']</b>
</pre>
</article>
</slide>
<slide>
<hgroup>
<h2>Spread Operator</h2>
</hgroup>
<article>
<p>
<h4>Spread Return Vals</h4>
</p>
<pre class="prettyprint" data-lang="javascript">
function getNums(){
return [1, 2, 3];
}
var b = [0, <b>...getNums()</b>];
<b>log(b); // [0, 1, 2, 3]</b>
</pre>
</article>
</slide>
<!-- -->
<slide class="segue dark quote nobackground">
<aside class="gdbar right bottom"><img src="images/es6.png"></aside>
<article class="flexbox vleft auto-fadein">
<h2>Spread Operator</h2>
<h3>Questions???</h3>
<div class="author">
#ES6 #frontendmasters @js_dev
</div>
</article>
</slide>
<slide>
<hgroup>
<h2>TRY THIS</h2>
</hgroup>
<article>
<ul>
<li><b>Spread</b> in <a href="http://google.github.io/traceur-compiler/demo/repl.html#%2F%2F%20Options%3A%20--annotations%20--array-comprehension%20--async-functions%20--block-binding%20--exponentiation%20--generator-comprehension%20--symbols%20--types%0A%0A">Traceur Repl</a></li>
<li><b>Spread</b> in Firefox</li>
<li>Spread a Rest Param</li>
<li>New Arrays on-the-fly</li>
</ul>
</article>
</slide>
<slide class="backdrop"></slide>
</slides>
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>