@@ -74,16 +74,38 @@ Waiting a certain amount of time can be easily done using the [`setTimeout()`](h
> **danger** Regular functions declared with the **`function` keyword have `this` inherited from the caller**, whereas **arrow functions have a `this` inherited from the declaring scope**.
<details><summary> Show the game.js file </summary>
??? Show the game.js file
=== "game.js - with function"
``` js
exportclassGameComponent{
goToScore(){
// ...
setTimeout(
function (){
=== "game.js - with function"
``` js
exportclassGameComponent{
goToScore(){
// ...
setTimeout(
function (){
constscorePage="#score";
scorePage+
"?name="+
this._name+
"&size="+
this._size+
"&time="+
timeElapsedInSeconds;
}.bind(this),
750
);
}
}
```
=== "game.js - with arrow function"
``` js
exportclassGameComponent{
goToScore(){
// ...
setTimeout(()=>{
constscorePage="#score";
scorePage+
"?name="+
...
...
@@ -92,34 +114,11 @@ Waiting a certain amount of time can be easily done using the [`setTimeout()`](h