mirror of
https://github.com/JeremyLikness/vanillajs-deck
synced 2025-12-15 10:43:34 +00:00
What's new with js
This commit is contained in:
21
slides/150-destructuring.html
Normal file
21
slides/150-destructuring.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<title>Destructuring</title>
|
||||
<h1>Destructuring</h1>
|
||||
<pre>
|
||||
var [x,y] = [1,2];
|
||||
// x=1, y=2
|
||||
[x,y] = [y,x];
|
||||
// x=2, y=1
|
||||
</pre>
|
||||
<pre class="appear">
|
||||
const obj = { foo: "bar", bar: "foo" };
|
||||
const {foo: f, bar} = obj;
|
||||
// f = "bar", bar = "foo";
|
||||
</pre>
|
||||
<pre class="appear">
|
||||
const twoRandos = () => [Math.random(), Math.random()];
|
||||
const randos = twoRandos();
|
||||
// [0.45235454, 0.6455656]
|
||||
const [random1, random2] = twoRandos();
|
||||
// random1 = 0.45235454, random2 = 0.6455656
|
||||
</pre>
|
||||
<next-slide>160-classes</next-slide>
|
||||
Reference in New Issue
Block a user