From e1fa68b06ee6e47751e32d409b30cb33675b79d4 Mon Sep 17 00:00:00 2001 From: oabdelnour <oabdelnour@takima.fr> Date: Mon, 26 Feb 2024 16:55:16 +0100 Subject: [PATCH] wip --- .../docs/docs/chapters/tp/arrow-functions.md | 93 +++++++++---------- 1 file changed, 44 insertions(+), 49 deletions(-) diff --git a/resources/docs/docs/chapters/tp/arrow-functions.md b/resources/docs/docs/chapters/tp/arrow-functions.md index 9963092..0300c59 100644 --- a/resources/docs/docs/chapters/tp/arrow-functions.md +++ b/resources/docs/docs/chapters/tp/arrow-functions.md @@ -74,57 +74,52 @@ 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**. -??? note - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod - nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor - massa, nec semper lorem quam in massa. - - ??? Show the game.js file - - === "game.js - with function" - - ``` js - export class GameComponent { - goToScore() { - // ... - setTimeout( - function () { - const scorePage = "#score"; - scorePage + - "?name=" + - this._name + - "&size=" + - this._size + - "&time=" + - timeElapsedInSeconds; - }.bind(this), - 750 - ); - } - } - ``` - - === "game.js - with arrow function" - - ``` js - export class GameComponent { - goToScore() { - // ... - setTimeout(() => { - const scorePage = "#score"; - scorePage + - "?name=" + - this._name + - "&size=" + - this._size + - "&time=" + - timeElapsedInSeconds; - }, 750); - } - } - ``` +??? Show the game.js file + + === "game.js - with function" + + ``` js + export class GameComponent { + goToScore() { + // ... + setTimeout( + function () { + const scorePage = "#score"; + scorePage + + "?name=" + + this._name + + "&size=" + + this._size + + "&time=" + + timeElapsedInSeconds; + }.bind(this), + 750 + ); + } + } + ``` + + === "game.js - with arrow function" + + ``` js + export class GameComponent { + goToScore() { + // ... + setTimeout(() => { + const scorePage = "#score"; + scorePage + + "?name=" + + this._name + + "&size=" + + this._size + + "&time=" + + timeElapsedInSeconds; + }, 750); + } + } + ``` ## Template literals -- GitLab