mirror of
https://github.com/JeremyLikness/vanillajs-deck
synced 2024-11-14 17:44:56 +00:00
21 lines
771 B
HTML
21 lines
771 B
HTML
<title>Arrow Functions (Gosinta)</title>
|
|
<h1>Arrow Functions (Gosinta)</h1>
|
|
<pre>
|
|
var solarsystem = {
|
|
planets: ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Pluto (?)'],
|
|
showPlanets: function() {
|
|
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 (?)'],
|
|
showPlanets: function() {
|
|
this.planets.forEach((planet, idx) => {
|
|
console.log(this.planets[idx]);});
|
|
}};
|
|
solarsystem.showPlanets(); // success! 🌍
|
|
</pre>
|
|
<next-slide>130-string-power</next-slide> |