What's new with js

This commit is contained in:
Jeremy Likness
2020-01-28 13:41:29 -08:00
parent dad9a93078
commit 2086a20e3c
7 changed files with 117 additions and 35 deletions

View File

@@ -2,25 +2,20 @@
<h1>Arrow Functions (Gosinta)</h1>
<pre>
var solarsystem = {
planets: ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter',
'Saturn', 'Uranus', 'Neptune', 'Pluto (?)'],
planets: ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Pluto (?)'],
showPlanets: function() {
this.planets.forEach(function(planet, idx) {
console.log(this.planets[idx]);
})
}
};
this.planets.forEach(function(planet, idx) {
console.log(this.planets[idx]);});
}};
solarsystem.showPlanets(); // crash! ⛔
</pre>
<pre class="appear">
var solarsystem = {
planets: ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter',
'Saturn', 'Uranus', 'Neptune', 'Pluto (?)'],
planets: ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Pluto (?)'],
showPlanets: function() {
this.planets.forEach((planet, idx) => {
console.log(this.planets[idx]);
})
}
};
this.planets.forEach((planet, idx) => {
console.log(this.planets[idx]);});
}};
solarsystem.showPlanets(); // success! 🌍
</pre>
</pre>
<next-slide>130-string-power</next-slide>