From c5a594387fc6b462c2b123e06165e6282fb6767f Mon Sep 17 00:00:00 2001 From: iamsaief Date: Wed, 15 May 2024 14:45:38 +0600 Subject: [PATCH 01/12] added bn translation 1-28 --- .gitignore | 1 + README.md | 1 + bn-BD/README_bn-BD.md | 5146 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 5148 insertions(+) create mode 100644 .gitignore create mode 100644 bn-BD/README_bn-BD.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..600d2d33 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vscode \ No newline at end of file diff --git a/README.md b/README.md index b203a060..33993983 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ From basic to advanced: test how well you know JavaScript, refresh your knowledg - [đŸ‡ģđŸ‡ŗ Tiáēŋng Viáģ‡t](./vi-VI/README-vi.md) - [đŸ‡¨đŸ‡ŗ įŽ€äŊ“中文](./zh-CN/README-zh_CN.md) - [🇹đŸ‡ŧ įšéĢ”ä¸­æ–‡](./zh-TW/README_zh-TW.md) +- [🇧🇩 āĻŦāĻžāĻ‚āϞāĻž](./bn-BD/README_bn-BD.md)

diff --git a/bn-BD/README_bn-BD.md b/bn-BD/README_bn-BD.md new file mode 100644 index 00000000..7f8d0060 --- /dev/null +++ b/bn-BD/README_bn-BD.md @@ -0,0 +1,5146 @@ +
+ +

āĻŦāĻžāĻ‚āϞāĻžā§Ÿ āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āĻĒā§āϰāĻļā§āύ⧋āĻ¤ā§āϤāϰ 🇧🇩

+
+ +

+āĻŦ⧇āϏāĻŋāĻ• āĻĨ⧇āϕ⧇ āĻāĻĄāĻ­ā§āϝāĻžāĻ¨ā§āϏ: āφāĻĒāύāĻŋ āĻ•āϤāϟ⧁āϕ⧁ āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āϜāĻžāύ⧇āύ āĻĒāϰ⧀āĻ•ā§āώāĻž āĻ•āϰ⧁āύ, āφāĻĒāύāĻžāϰ āĻœā§āĻžāĻžāύāϕ⧇ āĻāĻ•āϟ⧁ āĻāĻžāϞāĻžāχ āĻ•āϰ⧇ āύāĻŋāύ āĻ…āĻĨāĻŦāĻž āφāĻĒāύāĻžāϰ āχāĻ¨ā§āϟāĻžāĻ°ā§āĻ­āĻŋāωāϰ āϜāĻ¨ā§āϝ āĻĒā§āϰāĻ¸ā§āϤ⧁āϤāĻŋ āύāĻŋāύ đŸ’ĒāĨ¤ āĻāχ āϰāĻŋāĻĒā§‹ āύāĻŋ⧟āĻŋāĻŽāĻŋāϤ āφāĻĒāĻĄā§‡āϟ āĻ•āϰāĻž āĻšā§Ÿ āύāϤ⧁āύ āĻĒā§āϰāĻļā§āύāĻ¤ā§āϤāϰ āĻĻāĻŋā§Ÿā§‡āĨ¤ āωāĻ¤ā§āϤāϰāϗ⧁āϞ⧋ āĻ•āĻ˛ā§āϝāĻžāĻĒā§āϏāĻĄ āφāĻ•āĻžāϰ⧇ āφāϛ⧇, āĻĻ⧇āĻ–āĻžāϰ āϜāĻ¨ā§āϝ āωāĻ¤ā§āϤāϰ āĻ āĻ•ā§āϞāĻŋāĻ• āĻ•āϰ⧁āύāĨ¤ āĻ…āĻŦāϏāϰ⧇ āφāύāĻ¨ā§āĻĻ⧇āϰ āϜāĻ¨ā§āϝ āφāĻŽāĻŋ āĻāϟāĻžāϕ⧇ āĻŦāĻžāĻ‚āϞāĻžā§Ÿ āĻ…āύ⧁āĻŦāĻžāĻĻ āĻ•āϰ⧇āĻ›āĻŋ, āϭ⧁āϞ āĻ¤ā§āϰ⧁āϟāĻŋ āĻŽāĻžāĻ°ā§āϜāύāĻž āĻ•āϰāĻŦ⧇āύāĨ¤ āφāĻĒāύāĻžāϰ āĻĒā§āϰ⧋āĻ—ā§āϰāĻžāĻŽāĻŋāĻ‚ āϝāĻžāĻ¤ā§āϰāĻžāϰ āϜāĻ¨ā§āϝ āĻļ⧁āĻ­āĻ•āĻžāĻŽāύāĻž 💛āĨ¤

+ +

āφāĻŽāĻžāϰ āϏāĻžāĻĨ⧇ āϝ⧋āĻ—āĻžāϝ⧋āĻ— āĻ•āϰāϤ⧇ āϚāĻžāχāϞ⧇,

+ +

+ Facebook || LinkedIn || Blog +

+ +--- + +
āϝ⧇ āϝ⧇ āĻ­āĻžāώāĻžā§Ÿ āĻ…āύ⧁āĻŦāĻžāĻĻāϗ⧁āϞ⧋ āφāϛ⧇ āϤāĻžāϰ āϞāĻŋāĻ¸ā§āϟ - 🇸đŸ‡ĻđŸ‡ĒđŸ‡Ŧ🇧đŸ‡Ļ🇩đŸ‡ĒđŸ‡Ē🇸đŸ‡ĢđŸ‡ˇđŸ‡ŽđŸ‡ŠđŸ‡¯đŸ‡ĩđŸ‡°đŸ‡ˇđŸ‡ŗđŸ‡ąđŸ‡§đŸ‡ˇđŸ‡ˇđŸ‡ē🇹🇭🇹🇷đŸ‡ēđŸ‡ĻđŸ‡ģđŸ‡ŗđŸ‡¨đŸ‡ŗđŸ‡šđŸ‡ŧđŸ‡Ŋ🇰🇧🇩 +

+ +- [🇸đŸ‡Ļ Ø§Ų„ØšØąØ¨ŲŠØŠ](./ar-AR/README_AR.md) +- [đŸ‡ĒđŸ‡Ŧ Ø§Ų„Ų„ØēØŠ Ø§Ų„ØšØ§Ų…ŲŠØŠ](./ar-EG/README_ar-EG.md) +- [🇧đŸ‡Ļ Bosanski](./bs-BS/README-bs_BS.md) +- [🇩đŸ‡Ē Deutsch](./de-DE/README.md) +- [đŸ‡Ē🇸 EspaÃąol](./es-ES/README-ES.md) +- [đŸ‡Ģ🇷 Français](./fr-FR/README_fr-FR.md) +- [🇮🇩 Indonesia](./id-ID/README.md) +- [🇮🇹 Italiano](./it-IT/README.md) +- [đŸ‡¯đŸ‡ĩ æ—ĨæœŦčĒž](./ja-JA/README-ja_JA.md) +- [🇰🇷 한ęĩ­ė–´](./ko-KR/README-ko_KR.md) +- [đŸ‡ŗđŸ‡ą Nederlands](./nl-NL/README.md) +- [đŸ‡ĩ🇱 Polski](./pl-PL/README.md) +- [🇧🇷 PortuguÃĒs Brasil](./pt-BR/README_pt_BR.md) +- [🇷o RomÃĸnă](./ro-RO/README.ro.md) +- [🇷đŸ‡ē Đ ŅƒŅŅĐēиК](./ru-RU/README.md) +- [đŸ‡Ŋ🇰 Shqip](./sq-KS/README_sq_KS.md) +- [🇹🇭 āš„ā¸—ā¸ĸ](./th-TH/README-th_TH.md) +- [🇹🇷 TÃŧrkçe](./tr-TR/README-tr_TR.md) +- [đŸ‡ēđŸ‡Ļ ĐŖĐēŅ€Đ°Ņ—ĐŊҁҌĐēа ĐŧОва](./uk-UA/README.md) +- [đŸ‡ģđŸ‡ŗ Tiáēŋng Viáģ‡t](./vi-VI/README-vi.md) +- [đŸ‡¨đŸ‡ŗ įŽ€äŊ“中文](./zh-CN/README-zh_CN.md) +- [🇹đŸ‡ŧ įšéĢ”ä¸­æ–‡](./zh-TW/README_zh-TW.md) +- [🇧🇩 āĻŦāĻžāĻ‚āϞāĻž](./bn-BD/README_bn-BD.md) + +

+
+ +--- + +###### 1. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function sayHi() { + console.log(name); + console.log(age); + var name = "Lydia"; + let age = 21; +} + +sayHi(); +``` + +- A: `Lydia` and `undefined` +- B: `Lydia` and `ReferenceError` +- C: `ReferenceError` and `21` +- D: `undefined` and `ReferenceError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +āφāĻŽāϰāĻž āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āϭ⧇āϤāϰ⧇ āĻĒā§āϰāĻĨāĻŽā§‡ `var` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄ āĻĻāĻŋā§Ÿā§‡ āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰ⧇āĻ›āĻŋāĨ¤ āĻŽāĻžāύ⧇ āĻšāϞ āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞāϟāĻŋ āĻšāχāĻ¸ā§āĻŸā§‡āĻĄ (āĻŽā§‡āĻŽāϰāĻŋāϤ⧇ āϜāĻžā§ŸāĻ—āĻž āύāĻŋāĻšā§āϛ⧇ āϰāĻžāύ āĻ•āϰāĻžāϰ āϏāĻŽā§Ÿ) āĻšā§Ÿā§‡ āϝāĻžāĻšā§āϛ⧇ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻ­ā§āϝāĻžāϞ⧁ `undefined` āĻĻāĻŋā§Ÿā§‡ āϝāϤāĻ•ā§āώāύ āύāĻž āĻĒāĻ°ā§āϝāĻ¨ā§āϤ āϝ⧇ āϞāĻžāχāύ⧇ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇ āϏ⧇āĻ–āĻžāύ⧇ āϝāĻžāĻšā§āϛ⧇āĨ¤ āϝ⧇ āϞāĻžāχāύ⧇ āφāĻŽāϰāĻž āĻāϟāĻžāϕ⧇ āϞāĻ— āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāĻ›āĻŋ āϤāĻžāϰ āφāĻ— āĻĒāĻ°ā§āϝāĻ¨ā§āϤ āĻāϟāĻžāϕ⧇ āĻĄāĻŋāĻĢāĻžāχāύ āĻ•āϰāĻž āĻšā§ŸāύāĻŋ, āϤāĻžāχ āĻāϟāĻž āĻāĻ–āύ āĻĒāĻ°ā§āϝāĻ¨ā§āϤ `undefined` āĻ­ā§āϝāĻžāϞ⧁āϕ⧇āχ āϧāϰ⧇ āϰ⧇āϖ⧇āϛ⧇āĨ¤ + +`let` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄ (āĻāĻŦāĻ‚ `const`) āĻĻāĻŋā§Ÿā§‡ āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞ āύāĻŋāϞ⧇ āϏ⧇āϟāĻžāĻ“ āĻšāχāĻ¸ā§āĻŸā§‡āĻĄ āĻšā§Ÿ āϤāĻŦ⧇ `var` āĻāϰ āĻŽāϤ āχāύāĻŋāĻļāĻŋ⧟āĻžāϞāĻžāχāϜ āĻšā§Ÿ āύāĻžāĨ¤ āϝ⧇ āϞāĻžāχāύ⧇ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ (āχāύāĻŋāĻļāĻŋ⧟āĻžāϞāĻžāχāϜ) āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇ āϤāĻžāϰ āφāϗ⧇ āϤāĻžāĻĻ⧇āϰāϕ⧇ āĻāĻ•ā§āϏ⧇āϏ (āϰāĻŋāĻĄ/āϰāĻžāχāϟ) āĻ•āϰāĻž āϝāĻžā§Ÿ āύāĻžāĨ¤ āĻāϟāĻžāϕ⧇ "āĻŸā§‡āĻŽā§āĻĒā§‹āϰāĻžāϞ āĻĄā§‡āĻĄ āĻœā§‹āύ āĻŦāϞāĻž āĻšā§Ÿ"āĨ¤ āϝāĻ–āύ āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞāϕ⧇ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰāĻžāϰ āφāϗ⧇āχ āϤāĻžāϕ⧇ āĻāĻ•ā§āϏ⧇āϏ āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāĻž āĻšā§Ÿ āϤāĻ–āύ āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ `ReferenceError` āϛ⧁āρāĻā§œā§‡ āĻĻā§‡ā§ŸāĨ¤ + +

+
+ +--- + +###### 2. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +for (var i = 0; i < 3; i++) { + setTimeout(() => console.log(i), 1); +} + +for (let i = 0; i < 3; i++) { + setTimeout(() => console.log(i), 1); +} +``` + +- A: `0 1 2` and `0 1 2` +- B: `0 1 2` and `3 3 3` +- C: `3 3 3` and `0 1 2` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āĻŸā§‡āϰ āχāϭ⧇āĻ¨ā§āϟ āĻ•āĻŋāĻ‰ā§Ÿā§‡āϰ āϜāĻ¨ā§āϝ `setTimeout` āĻ•āϞāĻŦā§āϝāĻžāĻ• āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻ•āϞ āĻšā§Ÿā§‡āϛ⧇ āϞ⧁āĻĒāϟāĻŋ āϰāĻžāύ āĻšāĻ“ā§ŸāĻžāϰ āĻĒāϰ⧇āĨ¤ āϝ⧇āĻšā§‡āϤ⧁ ā§§āĻŽ āϞ⧁āĻĒ⧇ `var` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄ āĻŦā§āϝāĻžāĻŦāĻšā§ƒāϤ āĻšā§Ÿā§‡āϛ⧇ āĻāϟāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁ āϤāĻžāχ āĻ—ā§āϞ⧋āĻŦāĻžāϞāĨ¤ āϞ⧁āĻĒ āϚāϞāĻžāĻ•āĻžāϞ⧀āύ āφāĻŽāϰāĻž `i` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻĒā§āϰāϤāĻŋāĻŦāĻžāϰ `1` āĻ•āϰ⧇ āĻŦāĻžā§œāĻŋā§Ÿā§‡āĻ›āĻŋ āωāύāĻžāϰāĻŋ `++` āĻ…āĻĒāĻžāϰ⧇āϟāϰ āĻĻāĻŋā§Ÿā§‡āĨ¤ āϝāϤāĻ•ā§āώāϪ⧇ `setTimeout` āĻ•āϞāĻŦā§āϝāĻžāĻ• āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻ•āϞ āĻšā§Ÿā§‡āϛ⧇, ā§§āĻŽ āωāĻĻāĻžāĻšāϰāύ⧇āϰ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, `i` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āϤāϤāĻ•ā§āώāϪ⧇ `3` āĻšā§Ÿā§‡ āϗ⧇āϛ⧇āĨ¤ + +⧍⧟ āϞ⧁āĻĒ⧇, `i` āĻ­ā§āϝāĻžāϰāĻŋāϰāĻŋā§Ÿā§‡āĻŦāϞ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇ `let` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄ āĻĻāĻŋā§Ÿā§‡, `let` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄ (āĻāĻŦāĻ‚ `const`) āĻĻāĻŋā§Ÿā§‡ āĻ¨ā§‡ā§ŸāĻž āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϗ⧁āϞ⧋ āĻŦā§āϞāĻ•-āĻ¸ā§āϕ⧋āĻĒāĻĄ (āĻŦā§āϞāĻ• āĻšāĻšā§āϛ⧇ `{}` āĻāϰ āĻŽāĻ§ā§āϝ⧇ āĻĨāĻžāĻ•āĻž āĻ•āĻŋāϛ⧁)āĨ¤ āϞ⧁āĻĒ āϚāϞāĻžāĻ•āĻžāϞ⧀āύ āĻĒā§āϰāϤāĻŋāĻŦāĻžāϰāχ `i` āĻāϰ āύāϤ⧁āύ āĻ­ā§āϝāĻžāϞ⧁ āĻšāĻŦ⧇ āĻāĻŦāĻ‚ āĻĒā§āϰāϤāĻŋāϟāĻŋ āĻ­ā§āϝāĻžāϞ⧁āχ āϞ⧁āĻĒ⧇āϰ āϭ⧇āϤāϰ⧇ āĻ¸ā§āϕ⧋āĻĒāĻĄ āĻĨāĻžāĻ•āĻŦ⧇āĨ¤ + +

+
+ +--- + +###### 3. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const shape = { + radius: 10, + diameter() { + return this.radius * 2; + }, + perimeter: () => 2 * Math.PI * this.radius, +}; + +console.log(shape.diameter()); +console.log(shape.perimeter()); +``` + +- A: `20` and `62.83185307179586` +- B: `20` and `NaN` +- C: `20` and `63` +- D: `NaN` and `63` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +> āĻ–ā§‡ā§ŸāĻžāϞ āĻ•āϰ⧁āύ āĻāĻ–āĻžāύ⧇ `diameter` āĻāĻ•āϟāĻŋ āϏāĻžāϧāĻžāϰāύ āĻĢāĻžāĻ‚āĻļāύ āĻ…āĻ¨ā§āϝāĻĻāĻŋāϕ⧇ `perimeter` āĻšāĻšā§āϛ⧇ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧋ āĻĢāĻžāĻ‚āĻļāύāĨ¤ + +āĻ…ā§āϝāĻžāϰ⧋ āĻĢāĻžāĻ‚āĻļāύ⧇āϰ `this` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄ āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ¸ā§āϕ⧋āĻĒāϕ⧇ āϰ⧇āĻĢāĻžāϰ (āĻĒā§Ÿā§‡āĻ¨ā§āϟ) āĻ•āϰ⧇, āĻ•āĻŋāĻ¨ā§āϤ⧁ āϏāĻžāϧāĻžāϰāύ āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āύāĻŋāĻœā§‡āϰ āĻ¸ā§āϕ⧋āĻĒ⧇āχ āĻĒā§Ÿā§‡āĻ¨ā§āϟ āĻ•āϰ⧇āĨ¤ āĻŽāĻžāύ⧇ āĻšāϞ, āϝāĻ–āύ āφāĻŽāϰāĻž `perimeter` āϕ⧇ āĻ•āϞ āĻ•āϰāĻ›āĻŋ āĻāϟāĻž shape āĻ…āĻŦā§āĻœā§‡āĻ•ā§āϟ āϕ⧇ āϰ⧇āĻĢāĻžāϰ āĻ•āϰāϛ⧇ āύāĻž āĻŦāϰāĻ‚ āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ¸ā§āϕ⧋āĻĒāϕ⧇ āĻ•āϰāϛ⧇ (āωāĻĻāĻžāĻšāϰāύāĻ¸ā§āĻŦāϰ⧂āĻĒ - window)āĨ¤ + +āϝ⧇āĻšā§‡āϤ⧁ āĻ…ā§āϝāĻžāϰ⧋ āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āĻ¸ā§āϕ⧋āĻĒ⧇ `radius` āĻāϰ āϕ⧋āύ āĻ­ā§āϝāĻžāϞ⧁ āύ⧇āχ `this.radius` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇ `undefined` āĻāϕ⧇ ⧍ āĻĻāĻŋā§Ÿā§‡ āϗ⧁āύ āĻ•āϰāĻžāϰ āĻĢāϞ⧇ (`2 * Math.PI`) āĻĢāϞāĻžāĻĢāϞ āφāϏāϛ⧇ `NaN`. + +

+
+ +--- + +###### 4. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript ++true; +!"Lydia"; +``` + +- A: `1` and `false` +- B: `false` and `NaN` +- C: `false` and `false` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +āĻāĻ–āĻžāύ⧇ āχāωāύāĻžāϰāĻŋ (`+`) āĻ…āĻĒāĻžāϰ⧇āϟāϰāϟāĻŋ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰ⧇āϛ⧇ āϤāĻžāϰ āĻ…āĻĒāĻžāϰ⧇āĻ¨ā§āĻĄāϕ⧇ āύāĻžāĻŽā§āĻŦāĻžāϰ āĻ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāĻžāϰāĨ¤ `true` āĻšā§Ÿ `1`, āĻāĻŦāĻ‚ `false` āĻšā§Ÿ `0`āĨ¤ + +`'Lydia'` āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āϟāĻŋ āĻāĻ•āϟāĻŋ āϏāĻ¤ā§āϝ āĻ­ā§āϝāĻžāϞ⧁āĨ¤ āφāĻŽāϰāĻž āĻāĻ–āĻžāύ⧇ āφāϏāϞ⧇ `!` āĻĻāĻŋā§Ÿā§‡ āϝ⧇āϟāĻž āϜāĻŋāĻœā§āĻžā§‡āϏ āĻ•āϰāĻ›āĻŋ "āĻāχ āϏāĻ¤ā§āϝ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻ•āĻŋ āĻŽāĻŋāĻĨā§āϝāĻž ?"āĨ¤ āĻāϟāĻŋ āĻĢāϞāĻžāĻĢāϞ āĻĻāĻŋāĻšā§āϛ⧇ `false`āĨ¤ + + +

+
+ +--- + +###### 5. āĻāĻ–āĻžāύ⧇ āϕ⧋āύāϟāĻŋ āϏāĻ¤ā§āϝ? + +```javascript +const bird = { + size: "small", +}; + +const mouse = { + name: "Mickey", + small: true, +}; +``` + +- A: `mouse.bird.size` is not valid +- B: `mouse[bird.size]` is not valid +- C: `mouse[bird["size"]]` is not valid +- D: All of them are valid + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āĻŸā§‡ āĻ…āĻŦā§āϜāĻ•ā§āĻŸā§‡āϰ āϏāĻ•āϞ āĻ•āĻŋ-āχ āĻšāĻšā§āϛ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ (āϝāĻĻāĻŋ āύāĻž āĻāϟāĻž āϕ⧋āύ āϏāĻ‚āϕ⧇āϤ āĻšā§Ÿ)āĨ¤ āϝāĻĻāĻŋāĻ“āĻŦāĻž āφāĻŽāϰāĻž āĻāĻĻ⧇āϰāϕ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻšāĻŋāϏ⧇āĻŦ⧇ āϞāĻŋāϖ⧇ āύāĻžāĻ“ āĻĨāĻžāĻ•āĻŋ, āϭ⧇āϤāϰ⧇ āϭ⧇āϤāϰ⧇ āϤāĻž āϏāĻŦāϏāĻŽā§Ÿāχ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻšā§Ÿā§‡ āϝāĻžā§ŸāĨ¤ + +āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āĻ¸ā§āĻŸā§‡āϟāĻŽā§āϝāĻžāĻ¨ā§āϟ āϕ⧇ āĻ­āĻžāώāĻžāĻ¨ā§āϤāϰ (āĻŽā§‡āĻļāĻŋāύ⧇āϰ āĻ­āĻžāώāĻž) āĻ•āϰ⧇āĨ¤ āϝāĻ–āύ āĻŦā§āĻ°ā§āϝāĻžāϕ⧇āϟ āύ⧋āĻŸā§‡āĻļāύ āĻŦā§āϝāĻŦāĻšā§ƒāϤ āĻšā§Ÿ, āĻāϟāĻž āĻļ⧁āϰ⧁āϰ āĻŦā§āĻ°ā§āϝāĻžāϕ⧇āϟ `[` āĻĒ⧇āϞ⧇ āϤāĻž āĻļ⧇āώ āĻŦā§āĻ°ā§āϝāĻžāϕ⧇āϟ āĻĒāĻ°ā§āϝāĻ¨ā§āϤ `]` āϝ⧇āϤ⧇ āĻĨāĻžāϕ⧇āĨ¤ āϤāĻžāϰāĻĒāϰāχ āϕ⧇āĻŦāϞ āĻāϟāĻžāϰ āĻŽāĻžāύ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĻž āĻšāĻŦ⧇āĨ¤ + +āĻ…āĻ¨ā§āϝāĻĻāĻŋāϕ⧇, āĻĄāϟ āύ⧋āĻŸā§‡āĻļāύ⧇āϰ āĻŦ⧇āϞāĻžā§Ÿ āĻāϰāĻ•āĻŽāϟāĻž āϘāĻŸā§‡ āύāĻžāĨ¤ `mouse` āĻāϰ āĻŽāĻ§ā§āϝ⧇ `bird` āύāĻžāĻŽā§‡āϰ āϕ⧋āύ āĻ•āĻŋ āύ⧇āχ, āϤāĻžāϰ āĻŽāĻžāύ⧇ āĻšāĻšā§āϛ⧇ `mouse.bird` āĻšā§Ÿ `undefined`āĨ¤ āĻāϰāĻĒāϰ āĻĄāϟ āύ⧋āĻŸā§‡āĻļāύ āĻŦā§āϝāĻžāĻŦāĻšāĻžāϰ (`mouse.bird.size`) āĻ•āϰ⧇ āφāĻŽāϰāĻž āϜāĻžāύāϤ⧇ āϚāĻžāĻšā§āĻ›āĻŋ `size` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĨ¤ āϝ⧇āĻšā§‡āϤ⧁ `mouse.bird` āĻšā§Ÿ `undefined`, āφāĻŽāϰāĻž āφāϏāϞ⧇ āϜāĻžāύāϤ⧇ āϚāĻžāĻšā§āĻ›āĻŋ `undefined.size`āĨ¤ āĻāϟāĻž āĻŦ⧈āϧ āύ⧟, āĻāĻŦāĻ‚ `Cannot read property "size" of undefined` -āϰ āĻŽāϤ āĻāĻ•āϟāĻž āĻāϰāϰ āϛ⧁āĻā§œā§‡ āĻĻā§‡ā§ŸāĻž āĻšāĻŦ⧇āĨ¤ + +

+
+ +--- + +###### 6. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +let c = { greeting: "Hey!" }; +let d; + +d = c; +c.greeting = "Hello"; +console.log(d.greeting); +``` + +- A: `Hello` +- B: `Hey!` +- C: `undefined` +- D: `ReferenceError` +- E: `TypeError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āĻŸā§‡, āϏāĻŦ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāχ āĻ•āĻžāϜ āĻ•āϰ⧇ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āĻšāĻŋāϏ⧇āĻŦ⧇, āϝāĻ–āύ āφāĻŽāϰāĻž āĻāĻ•āϟāĻŋāϕ⧇ āĻ…āĻ¨ā§āϝāϟāĻŋāϰ āϏāĻŽāĻžāύ āĻ­ā§āϝāĻžāϞ⧁ āϏ⧇āϟ āĻ•āϰāĻ›āĻŋ āϤāĻ–āύ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏāχ āϏ⧇āϟ āĻšāĻšā§āϛ⧇āĨ¤ + +āĻĒā§āϰāĻĨāĻŽā§‡, āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞ `c` āĻāĻ•āϟāĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻŽāĻžāύ āϧāϰ⧇ āϰāĻžāϖ⧇āĨ¤ āĻĒāϰāĻŦāĻ°ā§āϤāĻŋāϤ⧇ āϏ⧇āχ āĻ­ā§āϝāĻžāϞāĻŋāωāχ āφāĻŽāϰāĻž `d` āϤ⧇ āĻ…ā§āϝāĻžāϏāĻžāχāύ āĻ•āϰāĻ›āĻŋ āϝ⧇āϟāĻžā§Ÿ āφāĻĻāϤ⧇ āφāϛ⧇ `c` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏāĨ¤ + + + +āϝāĻ–āύ āφāĻĒāύāĻŋ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻŽāĻžāύ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāϛ⧇āύ, āφāĻĒāύāĻŋ āϏāĻŦāϗ⧁āϞ⧋āϕ⧇āχ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāϛ⧇āύāĨ¤ + +

+
+ +--- + +###### 7. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +let a = 3; +let b = new Number(3); +let c = 3; + +console.log(a == b); +console.log(a === b); +console.log(b === c); +``` + +- A: `true` `false` `true` +- B: `false` `false` `true` +- C: `true` `false` `false` +- D: `false` `true` `true` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +`new Number()` āĻšāϞ āĻāĻ•āϟāĻŋ āĻŦāĻŋāĻ˛ā§āϟ-āχāύ āĻĢāĻžāĻ‚āĻļāύ āĻ•āĻ¨ā§āϏāĻŸā§āϰāĻžāĻ•ā§āϟāϰāĨ¤ āϝāĻĻāĻŋāĻ“ āĻāϟāĻž āύāĻžāĻŽā§āĻŦāĻžāϰ āĻāϰ āĻŽāϤ āĻĻ⧇āĻ–āϤ⧇ āĻ•āĻŋāĻ¨ā§āϤ⧁ āĻāϟāĻŋ āφāϏāϞ⧇ āύāĻžāĻŽā§āĻŦāĻžāϰ āύ⧟āσ āĻāϟāĻžāϤ⧇ āφāϰ āĻ…āύ⧇āĻ•āϗ⧁āϞ⧋ āĻĢāĻŋāϚāĻžāϰ āφāϛ⧇ āĻāĻŦāĻ‚ āĻāϟāĻŋ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāĨ¤ + +āϝāĻ–āύ āφāĻŽāϰāĻž `==` āĻ…āĻĒāĻžāϰ⧇āϟāϰ (āϏāĻŽāϤ⧁āĻ˛ā§āϝ āĻ…āĻĒāĻžāϰ⧇āϟāϰ) āĻŦā§āϝāĻžāĻŦāĻšāĻžāϰ āĻ•āϰāĻŋ, āĻāϟāĻž āϕ⧇āĻŦāϞ āĻ­ā§āϝāĻžāϞ⧁ āϏāĻŽāĻžāύ āĻ•āĻŋāύāĻž āϤ⧁āϞāύāĻž āĻ•āϰ⧇āĨ¤ `a` āĻ“ `b` āĻĻ⧁āϟāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁āχ `3` āϤāĻžāχ āĻĢāϞāĻžāĻĢāϞ āĻšā§Ÿ `true`āĨ¤ + +āĻ…āĻ¨ā§āϝāĻĻāĻŋāϕ⧇, āϝāĻ–āύ āφāĻŽāϰāĻž `===` āĻ…āĻĒāĻžāϰ⧇āϟāϰ (āĻ•āĻ ā§‹āϰ-āϏāĻŽāϤ⧁āĻ˛ā§āϝ āĻ…āĻĒāĻžāϰ⧇āϟāϰ) āĻŦā§āϝāĻžāĻŦāĻšāĻžāϰ āĻ•āϰāĻŋ, āĻāϟāĻž āĻ­ā§āϝāĻžāϞ⧁ āĻāĻŦāĻ‚ āϟāĻžāχāĻĒ āĻĻ⧁āϟāĻžāχ āϏāĻŽāĻžāύ āĻ•āĻŋāύāĻž āϤ⧁āϞāύāĻž āĻ•āϰ⧇āĨ¤ āĻāĻ•ā§āώāĻ¤ā§āϰ⧇ `new Number()` āϝ⧇āĻšā§‡āϤ⧁ āύāĻžāĻŽā§āĻŦāϰ āύ⧟ āĻ…āĻŦ⧇āĻœā§‡āĻ•ā§āϟāĨ¤ āĻĻ⧁āϟāχ āĻĢāϞāĻžāĻĢāϞ āĻĻā§‡ā§Ÿ `false`āĨ¤ + +

+
+ +--- + +###### 8. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +class Chameleon { + static colorChange(newColor) { + this.newColor = newColor; + return this.newColor; + } + + constructor({ newColor = "green" } = {}) { + this.newColor = newColor; + } +} + +const freddie = new Chameleon({ newColor: "purple" }); +console.log(freddie.colorChange("orange")); +``` + +- A: `orange` +- B: `purple` +- C: `green` +- D: `TypeError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +āĻāĻ–āĻžāύ⧇ `colorChange` āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§āϝāĻžāϟāĻŋāĻ• āĻĢāĻžāĻ‚āĻļāύāĨ¤ āĻāĻĻ⧇āϰ āĻĄāĻŋāϜāĻžāχāύ āĻĒā§āϝāĻžāϟāĻžāĻ°ā§āύ āĻšāϞ, āϕ⧇āĻŦāϞ āϝ⧇ āĻ•āĻ¨ā§āϏāĻŸā§āϰāĻžāĻ•ā§āϟāϰ⧇ āĻāĻĻ⧇āϰ āϤ⧈āϰāĻŋ āĻ•āϰāĻž āĻšāĻŦ⧇ āϤāĻžāϰ āĻŦāĻžāχāϰ⧇ āĻĨ⧇āϕ⧇ āĻāĻ•ā§āϏ⧇āϏ āĻ•āϰāĻž āϝāĻžāĻŦ⧇ āύāĻž, āĻāĻŦāĻ‚ āϕ⧋āύ āϚāĻŋāϞāĻĄā§āϰ⧇āύ⧇ āĻĒāĻžāϏ āĻ•āϰāĻž āϝāĻžāĻŦ⧇ āύāĻž āĻŦāĻž āĻ•ā§āϞāĻžāϏ āχāĻ¨ā§āϏāĻŸā§‡āĻ¨ā§āϏ āĻĻāĻŋā§Ÿā§‡ āĻ•āϞāĻ“ āĻ•āϰāĻž āϝāĻžāĻŦ⧇ āύāĻžāĨ¤ āϝ⧇āĻšā§‡āϤ⧁ `freddie` Chameleon āĻ•ā§āϞāĻžāϏ⧇āϰ āĻāĻ•āϟāĻŋ āχāĻ¨ā§āϏāĻŸā§‡āĻ¨ā§āϏ, āϤāĻžāχ āϏ⧇ āĻ¸ā§āĻŸā§āϝāĻžāϟāĻŋāĻ• āĻĢāĻžāĻ‚āĻļāύāϕ⧇ āĻ•āϞ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŦ⧇ āύāĻžāĨ¤ āĻĢāϞ⧇ `TypeError` āϛ⧋āρ⧜āĻž āĻšā§ŸāĨ¤ + +

+
+ +--- + +###### 9. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +let greeting; +greetign = {}; // Typo! +console.log(greetign); +``` + +- A: `{}` +- B: `ReferenceError: greetign is not defined` +- C: `undefined` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +āĻāϟāĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āϞāĻ— āĻ•āϰāϛ⧇, āĻ•āĻžāϰāύ āφāĻŽāϰāĻž āĻ–āĻžāϞāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϟāĻŋāϕ⧇ āϤ⧈āϰāĻŋ āĻ•āϰ⧇āĻ›āĻŋ āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻŽāĻ§ā§āϝ⧇! āϝāĻ–āύ `greeting` āϕ⧇ `greetign` āϭ⧁āϞ āĻŦāĻžāύāĻžāύ āĻ āϞāĻŋāϖ⧇āĻ›āĻŋ, āĻœā§‡āĻāϏ āχāĻ¨ā§āϟāĻžāϰāĻĒā§āϰ⧇āϟāĻžāϰ āĻĻ⧇āĻ–āϛ⧇ āĻāĻŽāύāσ + +1. āύ⧋āĻĄ āĻœā§‡āĻ“āĻāϏ āĻ - `global.greetign = {}`āĨ¤ +2. āĻŦā§āϰāĻžāωāϜāĻžāϰ āĻ - `window.greetign = {}`, `frames.greetign = {}` āĻāĻŦāĻ‚ `self.greetign`āĨ¤ +3. āĻ“ā§Ÿā§‡āĻŦ āĻ“ā§ŸāĻžāĻ°ā§āĻ•āĻžāĻ°ā§āϏ āĻ - `self.greetign`āĨ¤ +4. āĻ…āĻ¨ā§āϝ āϏāĻ•āϞ āĻāύāĻ­āĻžā§ŸāĻ°ā§āĻ¨ā§āĻŽā§‡āĻ¨ā§āĻŸā§‡ - `globalThis.greetign`āĨ¤ + +āĻāϟāĻžāϕ⧇ āĻā§œāĻžāύ⧋āϰ āϜāĻ¨ā§āϝ āφāĻŽāϰāĻž `"use strict"` āĻŦā§āϝāĻžāĻŦāĻšāĻžāϰ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ āĨ¤ āĻāϟāĻž āύāĻŋāĻļā§āϚāĻŋāϤ āĻ•āϰāĻŦ⧇ āϝ⧇ āφāĻĒāύāĻŋ āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞāϕ⧇ āϕ⧋āύ āĻ•āĻŋāϛ⧁ āĻĻāĻŋā§Ÿā§‡ āĻ…ā§āϝāĻžāϏāĻžāχāύ āĻ•āϰāĻžāϰ āφāϗ⧇ āϤāĻžāϕ⧇ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰ⧇āϛ⧇āύ āĻ•āĻŋāύāĻž āĨ¤ + +

+
+ +--- + +###### 10. āφāĻŽāϰāĻž āĻāϟāĻž āĻ•āϰāϞ⧇ āĻ•āĻŋ āϘāϟāĻŦ⧇? + +```javascript +function bark() { + console.log("Woof!"); +} + +bark.animal = "dog"; +``` + +- A: Nothing, this is totally fine! +- B: `SyntaxError`. You cannot add properties to a function this way. +- C: `"Woof"` gets logged. +- D: `ReferenceError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āĻŸā§‡ āĻāϟāĻž āϏāĻŽā§āĻ­āĻŦ, āĻ•āĻžāϰāύ āĻĢāĻžāĻ‚āĻļāύāϗ⧁āϞ⧋ āĻšā§Ÿ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ! (āĻĒā§āϰāĻŋāĻŽāĻŋāϟāĻŋāĻ­ āϟāĻžāχāĻĒ āĻŦāĻžāĻĻ⧇ āϏāĻŦāĻ•āĻŋāϛ⧁āχ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ) + +āĻĢāĻžāĻ‚āĻļāύāϗ⧁āϞ⧋ āĻšā§Ÿ āĻŦāĻŋāĻļ⧇āώ āϧāϰāύ⧇āϰ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāĨ¤ āϝ⧇ āϕ⧋āĻĄāϟāĻž āφāĻĒāύāĻŋ āϞāĻŋāϖ⧇āϛ⧇āύ āĻāϟāĻž āφāϏāϞ āĻĢāĻžāĻ‚āĻļāύ āύ⧟āĨ¤ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻšāĻšā§āϛ⧇ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āϝāĻžāϰ āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋāϏ āĻ°ā§Ÿā§‡āϛ⧇āĨ¤ āĻāχ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϗ⧁āϞ⧋āϕ⧇ āĻ•āϞ āĻ•āϰāĻž āϝāĻžā§ŸāĨ¤ + + +

+
+ +--- + +###### 11. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function Person(firstName, lastName) { + this.firstName = firstName; + this.lastName = lastName; +} + +const member = new Person("Lydia", "Hallie"); +Person.getFullName = function () { + return `${this.firstName} ${this.lastName}`; +}; + +console.log(member.getFullName()); +``` + +- A: `TypeError` +- B: `SyntaxError` +- C: `Lydia Hallie` +- D: `undefined` `undefined` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āĻŸā§‡, āĻĢāĻžāĻ‚āĻļāύāϗ⧁āϞ⧋ āĻšā§Ÿ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ, āĻ…āϤāĻāĻŦ, `getFullName` āĻŽā§‡āĻĨāĻĄāϟāĻŋ āĻ•āĻ¨ā§āϏāĻŸā§āϰāĻžāĻ•ā§āϟāϰ āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϏāĻžāĻĨ⧇ āϝ⧁āĻ•ā§āϤ āĻšā§ŸāĨ¤ āĻāĻ•āĻžāϰāύ⧇āχ, āφāĻŽāϰāĻž `Person.getFullName()` āϕ⧇ āĻ•āϞ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻ›āĻŋ āĻ•āĻŋāĻ¨ā§āϤ⧁ `member.getFullName` āϛ⧁āĻā§œā§‡ āĻĻāĻŋāĻšā§āϛ⧇ `TypeError`āĨ¤ + +āφāĻĒāύāĻŋ āϝāĻĻāĻŋ āĻāĻ•āϟāĻŋ āĻŽā§‡āĻĨāĻĄāϕ⧇ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϏāĻ•āϞ āχāĻ¨ā§āϏāĻŸā§āϝāĻžāĻ¨ā§āϏ⧇āϰ āϜāĻ¨ā§āϝ āĻŦā§āϝāĻŦāĻšāĻžāϰāϝ⧋āĻ—ā§āϝ āĻ•āϰāϤ⧇ āϚāĻžāύ āϤāĻžāĻšāϞ⧇ āφāĻĒāύāĻžāϰ āĻāϟāĻžāϕ⧇ āϝ⧁āĻ•ā§āϤ āĻ•āϰāϤ⧇ āĻšāĻŦ⧇ āĻĒā§āϰāĻŸā§‹āϟāĻžāχāĻĒ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϤ⧇āĨ¤ + +```js +Person.prototype.getFullName = function () { + return `${this.firstName} ${this.lastName}`; +}; +``` + +

+
+ +--- + +###### 12. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function Person(firstName, lastName) { + this.firstName = firstName; + this.lastName = lastName; +} + +const lydia = new Person("Lydia", "Hallie"); +const sarah = Person("Sarah", "Smith"); + +console.log(lydia); +console.log(sarah); +``` + +- A: `Person {firstName: "Lydia", lastName: "Hallie"}` and `undefined` +- B: `Person {firstName: "Lydia", lastName: "Hallie"}` and `Person {firstName: "Sarah", lastName: "Smith"}` +- C: `Person {firstName: "Lydia", lastName: "Hallie"}` and `{}` +- D: `Person {firstName: "Lydia", lastName: "Hallie"}` and `ReferenceError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +āφāĻŽāϰāĻž `sarah` -āϰ āϜāĻ¨ā§āϝ `new` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄāϟāĻŋ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāĻŋāύāĻŋāĨ¤ āϝāĻ–āύ `new` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāĻž āĻšā§Ÿ `this` āϰ⧇āĻĢāĻžāϰ āĻ•āϰ⧇ āφāĻŽāϰāĻž āϤ⧈āϰāĻŋ āĻ•āϰāĻž āύāϤ⧁āύ āĻ–āĻžāϞāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāĻŋāϕ⧇āĨ¤ āĻ…āĻ¨ā§āϝāĻĻāĻŋāϕ⧇, āϝāĻĻāĻŋ āφāĻĒāύāĻŋ `new` āϝ⧁āĻ•ā§āϤ āύāĻž āĻ•āϰ⧇āύ, `this` āϰ⧇āĻĢāĻžāϰ āĻ•āϰāĻŦ⧇ **āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇** ! + +āφāĻŽāϰāĻž āĻŦāϞāĻ›āĻŋ `this.firstName` āϏāĻŽāĻžāύ āĻšāϞ `"Sarah"` āĻāĻŦāĻ‚ `this.lastName` āĻšāϞ `"Smith"`āĨ¤ āφāĻŽāϰāĻž āĻāĻ–āĻžāύ⧇ āφāϏāϞ⧇ āϝ⧇āϟāĻž āĻŦāϞāĻ›āĻŋ āϏ⧇āϟāĻž āĻšāϞ, āĻĄāĻŋāĻĢāĻžāχāύ āĻ•āϰāĻ›āĻŋ `global.firstName = 'Sarah'` āĻāĻŦāĻ‚ `global.lastName = 'Smith'`āĨ¤ āϝ⧇āĻšā§‡āϤ⧁ `Person` āĻĢāĻžāĻ‚āĻļāύ āϕ⧋āύ āĻĢāϞāĻžāĻĢāϞ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇ āύāĻž āϤāĻžāχ `sarah` āύāĻŋāĻœā§‡āχ āĻšā§Ÿā§‡ āφāϛ⧇ `undefined`āĨ¤ + +

+
+ +--- + +###### 13. What are the three phases of event propagation? + +- A: Target > Capturing > Bubbling +- B: Bubbling > Target > Capturing +- C: Target > Bubbling > Capturing +- D: Capturing > Target > Bubbling + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +**āĻ•ā§āϝāĻžāĻĒāϚāĻžāϰāĻŋāĻ‚** āĻ…āĻŦāĻ¸ā§āĻĨāĻžāϰ āϏāĻŽā§Ÿ, āχāϭ⧇āĻ¨ā§āϟ āĻĄāĻŽā§‡āϰ (DOM) āĻĒ⧁āĻ°ā§āĻŦāĻĒ⧁āϰ⧁āώ āωāĻĒāĻžāĻĻāĻžāύ āĻĨ⧇āϕ⧇ **āϞāĻ•ā§āĻˇā§āϝ** -āϰ āĻĻāĻŋāϕ⧇ āϝāĻžā§ŸāĨ¤ āϤāĻžāϰāĻĒāϰ āĻāϟāĻž **āϞāĻ•ā§āĻˇā§āϝ** āωāĻĒāĻžāĻĻāĻžāύ⧇ āĻĒ⧌āρāĻ›āĻžāϞ⧇ **āĻŦāĻžāĻŦāϞāĻŋāĻ‚** āĻļ⧁āϰ⧁ āĻšā§ŸāĨ¤ + + + +

+
+ +--- + +###### 14. āϏāĻ•āϞ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻĒā§āϰ⧋āĻŸā§‹āϟāĻžāχāĻĒ āφāϛ⧇? + +- A: true +- B: false + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +**āĻŦ⧇āχāϜ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ** āĻ›āĻžā§œāĻž āϏāĻ•āϞ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻĒā§āϰ⧋āĻŸā§‹āϟāĻžāχāĻĒ āφāϛ⧇āĨ¤ āĻŦ⧇āχāϜ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻšāϞ āϏ⧇ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āϝ⧇āϟāĻž āχāωāϜāĻžāϰ āϤ⧈āϰāĻŋ āĻ•āϰ⧇āϛ⧇ āĻ…āĻĨāĻŦāĻž `new` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄāϟāĻŋ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ āϤ⧈āϰāĻŋ āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇āĨ¤ āĻŦ⧇āχāϜ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻ•āĻŋāϛ⧁ āĻŦāĻŋāĻ˛ā§āϟāχāύ āĻŽā§‡āĻĨāĻĄ āĻŦā§āϝāĻŦāĻšāĻžāϰ⧇āϰ āĻŦ⧈āϧ āĻ…āύ⧁āĻŽāϤāĻŋ āφāϛ⧇, āϝ⧇āĻŽāύ `.toString`āĨ¤ āĻāχ āĻ•āĻžāϰāύ⧇āχ āφāĻĒāύāĻŋ āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āĻŸā§‡āϰ āĻŦāĻŋāĻ˛ā§āϟāχāύ āĻŽā§‡āĻĨāĻĄ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āύ! āĻāχāϰāĻ•āĻŽ āĻŽā§‡āĻĨāĻĄāϗ⧁āϞ⧋ āĻĒā§āϰ⧋āĻŸā§‹āϟāĻžāχāĻĒ⧇āϰ āĻ†ā§ŸāϤāĻžāϧ⧀āύ⧇ āĻĨāĻžāϕ⧇āĨ¤ āϝāĻĻāĻŋāĻ“ āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āφāĻĒāύāĻžāϰ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āϏāϰāĻžāϏāϰāĻŋ āĻāϗ⧁āϞ⧋āϕ⧇ āϖ⧁āρāĻœā§‡ āĻĒāĻžā§Ÿ āύāĻž, āĻĒā§āϰ⧋āĻŸā§‹āϟāĻžāχāĻĒ āĻšā§‡āχāύ⧇āϰ āϭ⧇āϤāϰ āĻĻāĻŋā§Ÿā§‡ āĻ¯ā§‡ā§Ÿā§‡ āϖ⧁āρāĻœā§‡ āĻŦ⧇āϰ āĻ•āϰ⧇, āĻĢāϞ⧇ āφāĻĒāύāĻŋ āĻāϗ⧁āϞ⧋ āĻŦā§āϝāĻŦāĻšāĻžāϰ⧇āϰ āĻŦ⧈āϧ āĻ…āύ⧁āĻŽāϤāĻŋ āĻĒāĻžāύāĨ¤ + +

+
+ +--- + +###### 15. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function sum(a, b) { + return a + b; +} + +sum(1, "2"); +``` + +- A: `NaN` +- B: `TypeError` +- C: `"12"` +- D: `3` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āĻāĻ•āϟāĻŋ **āĻĄāĻžā§ŸāύāĻžāĻŽāĻŋāĻ• āϟāĻžāχāĻĒ āĻ­āĻžāώāĻžāσ** āφāĻŽāϰāĻž āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞ⧇āϰ āϟāĻžāχāĻĒ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻ•āϰāĻŋ āύāĻžāĨ¤ āφāĻĒāύāĻŋ āϜāĻžāύāϤ⧇ āĻĒāĻžāϰ⧇āύ āύāĻž āĻ­ā§āϝāĻžāϞ⧁ āĻ¸ā§āĻŦ⧟āĻ‚āĻ•ā§āϰāĻŋ⧟āĻ­āĻžāĻŦ⧇āχ āĻāĻ• āϟāĻžāχāĻĒ āĻĨ⧇āϕ⧇ āĻ…āĻ¨ā§āϝ āϟāĻžāχāĻĒ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻšā§Ÿā§‡ āϝāĻžā§Ÿ, āϝ⧇āϟāĻžāϕ⧇ āĻŦāϞāĻž āĻšā§Ÿ **āĻ•ā§‹ā§ŸāĻžāĻ°ā§āĻļāύ (coercion)**āĨ¤ āĻāϟāĻž āĻšāϞ āĻāĻ• āϟāĻžāχāĻĒ āĻĨ⧇āϕ⧇ āĻ…āĻ¨ā§āϝ āϟāĻžāχāĻĒ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻšāĻ“ā§ŸāĻžāĨ¤ + +āĻāχ āωāĻĻāĻžāĻšāϰāύ⧇, āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āĻāχ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋāϕ⧇ āϝ⧁āĻ•ā§āϤāĻŋāϏāĻ™ā§āĻ—āϤ āĻ“ āĻāϰ āĻāĻ•āϟāĻŋ āĻĢāϞāĻžāĻĢāϞ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ `1` āύāĻžāĻŽā§āĻŦāĻžāϰāϟāĻŋāϕ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇āϛ⧇āĨ¤ āύāĻžāĻŽā§āĻŦāĻžāϰ `1` āĻ“ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ `"2"` āĻāϰ āϝ⧋āϗ⧇āϰ āĻŦ⧇āϞāĻžā§Ÿ āύāĻžāĻŽā§āĻŦāĻžāϰāϟāĻŋāϕ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻšāĻŋāϏ⧇āĻŦ⧇ āϧāϰāĻž āĻšā§Ÿā§‡āϛ⧇āĨ¤ āφāĻŽāϰāĻž āĻĻ⧁āĻŸā§‹ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āϕ⧇ āϝ⧁āĻ•ā§āϤ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ āĻāĻ­āĻžāĻŦ⧇, `"Hello" + "World"`, āϤāĻžāχ āĻāĻ–āĻžāύ⧇ `"1" + "2"` āĻĢāϞāĻžāĻĢāϞ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇ `"12"`āĨ¤ + +

+
+ +--- + +###### 16. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +let number = 0; +console.log(number++); +console.log(++number); +console.log(number); +``` + +- A: `1` `1` `2` +- B: `1` `2` `2` +- C: `0` `2` `2` +- D: `0` `1` `2` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +**āĻĒā§‹āĻ¸ā§āϟāĻĢāĻŋāĻ•ā§āϏ** āχāωāύāĻžāϰāĻŋ āĻ…āĻĒāĻžāϰ⧇āϟāϰ `++`: +1. āĻĢāϞāĻžāĻĢāϞ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ (āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `0`) +2. āĻ­ā§āϝāĻžāϞ⧁āϰ āĻŽāĻžāύ āĻŦ⧃āĻĻā§āϧāĻŋ āĻ•āϰ⧇ (āύāĻžāĻŽā§āĻŦāĻžāϰāϟāĻŋ āĻāĻ–āύ `1`) + +**āĻĒā§āϰāĻŋāĻĢāĻŋāĻ•ā§āϏ** āχāωāύāĻžāϰāĻŋ āĻ…āĻĒāĻžāϰ⧇āϟāϰ `++`: +1. āĻ­ā§āϝāĻžāϞ⧁āϰ āĻŽāĻžāύ āĻŦ⧃āĻĻā§āϧāĻŋ āĻ•āϰ⧇ (āύāĻžāĻŽā§āĻŦāĻžāϰāϟāĻŋ āĻāĻ–āύ `2`) +2. āĻĢāϞāĻžāĻĢāϞ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ (āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `2`) + +āĻāϜāĻ¨ā§āϝāχ āωāĻ¤ā§āϤāϰāϟāĻŋ āĻšā§Ÿ `0 2 2` + +

+
+ +--- + +###### 17. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function getPersonInfo(one, two, three) { + console.log(one); + console.log(two); + console.log(three); +} + +const person = "Lydia"; +const age = 21; + +getPersonInfo`${person} is ${age} years old`; +``` + +- A: `"Lydia"` `21` `["", " is ", " years old"]` +- B: `["", " is ", " years old"]` `"Lydia"` `21` +- C: `"Lydia"` `["", " is ", " years old"]` `21` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +āϝāĻĻāĻŋ āφāĻĒāύāĻŋ _āĻŸā§āϝāĻžāĻ—āĻĄ āĻŸā§‡āĻŽā§āĻĒāϞ⧇āϟ āϞāĻŋāϟāĻžāϰ⧇āϞāϏ_ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇āύ, āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ ā§§āĻŽ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āϏāĻŦāϏāĻŽā§Ÿ āĻšā§Ÿ āĻŸā§āϝāĻžāĻ—āĻĄ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āϗ⧁āϞ⧋āϰ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇āĨ¤ āĻŦāĻžāĻ•āĻŋ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞ⧋ āĻšā§Ÿ āϝ⧇āχ āĻāĻ•ā§āϏāĻĒā§āϰ⧇āĻļāύāϗ⧁āϞ⧋ āĻĒāĻžāĻ āĻžāύ⧋ āĻšā§Ÿ āϤāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁āĨ¤ + +

+
+ +--- + +###### 18. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function checkAge(data) { + if (data === { age: 18 }) { + console.log("You are an adult!"); + } else if (data == { age: 18 }) { + console.log("You are still an adult."); + } else { + console.log(`Hmm.. You don't have an age I guess`); + } +} + +checkAge({ age: 18 }); +``` + +- A: `You are an adult!` +- B: `You are still an adult.` +- C: `Hmm.. You don't have an age I guess` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +āϏāĻŽāϤāĻž āĻĒāϰ⧀āĻ•ā§āώāĻž āĻ•āϰāĻžāϰ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āĻŽā§ŒāϞāĻŋāĻ• āϟāĻžāχāĻĒāϗ⧁āϞ⧋ (primitives) _āĻ­ā§āϝāĻžāϞ⧁_ āĻāĻŦāĻ‚ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āϟāĻžāχāĻĒāϗ⧁āϞ⧋ _āϰ⧇āĻĢ⧇āϰāĻžāĻ¨ā§āϏ_ āĻĻā§āĻŦāĻžāϰāĻž āϤ⧁āϞāύāĻž āĻ•āϰāĻž āĻšā§ŸāĨ¤ āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āĻšā§‡āĻ• āĻ•āϰ⧇ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϗ⧁āϞ⧋āϤ⧇ āĻāĻ•āχ āĻŽā§‡āĻŽāϰāĻŋ āϞ⧋āϕ⧇āĻļāύ⧇āϰ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āφāϛ⧇ āĻ•āĻŋāύāĻžāĨ¤ + +āϝ⧇āĻĻ⧁āĻŸā§‹ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āφāĻŽāϰāĻž āϤ⧁āϞāύāĻž āĻ•āϰāĻ›āĻŋ āϤāĻžāĻĻ⧇āϰ āϏ⧇āϟāĻž āύ⧇āχāσ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ⧇ āφāĻŽāϰāĻž āϝ⧇ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āĻĒāĻžāĻ āĻŋā§Ÿā§‡āĻ›āĻŋ āϏ⧇āϟāĻžāϰ āĻŽā§‡āĻŽāϰāĻŋ āϞ⧋āϕ⧇āĻļāύ⧇āϰ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āϝ⧇āχ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϟāĻž āϏāĻŽāϤāĻž āĻšā§‡āĻ• āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ āĻŦā§āϝāĻžāĻŦāĻšāĻžāϰ āĻ•āϰ⧇āĻ›āĻŋ āϤāĻžāϰ āĻĨ⧇āϕ⧇ āφāϞāĻžāĻĻāĻžāĨ¤ + +āĻāĻ•āĻžāϰāύ⧇ āĻĻ⧁āĻŸā§‹āχ `{ age: 18 } === { age: 18 }` āĻāĻŦāĻ‚ `{ age: 18 } == { age: 18 }` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `false` + +

+
+ +--- + +###### 19. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function getAge(...args) { + console.log(typeof args); +} + +getAge(21); +``` + +- A: `"number"` +- B: `"array"` +- C: `"object"` +- D: `"NaN"` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +āĻāĻ–āĻžāύ⧇ āϰ⧇āĻ¸ā§āϟ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰāϟāĻŋ (`...args`) āφāĻŽāĻžāĻĻ⧇āϰāϕ⧇ āĻŦāĻžāĻ•āĻŋ āϏāĻŦ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟāϏāϕ⧇ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇āϤ⧇ "āϏāĻ‚āĻ—ā§āϰāĻš" āĻ•āϰāϤ⧇ āĻĻā§‡ā§ŸāĨ¤ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇ āĻšā§Ÿ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ, āϤāĻžāχ `typeof args` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `"object"`āĨ¤ + +

+
+ +--- + +###### 20. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function getAge() { + "use strict"; + age = 21; + console.log(age); +} + +getAge(); +``` + +- A: `21` +- B: `undefined` +- C: `ReferenceError` +- D: `TypeError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +`"use strict"` āĻĻā§āĻŦāĻžāϰāĻž āφāĻĒāύāĻŋ āĻāϟāĻž āύāĻŋāĻļā§āϚāĻŋāϤ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āύ āϝ⧇ āφāĻĒāύāĻŋ āĻĻ⧁āĻ°ā§āϘāϟāύāĻžāĻŦāĻļāϤ āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰāϛ⧇āύ āύāĻžāĨ¤ āφāĻŽāϰāĻž āϕ⧋āĻĨāĻžāĻ“ `age` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞāϟāĻŋ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰāĻŋāύāĻŋ āĻāĻŦāĻ‚ āϝ⧇āĻšā§‡āϤ⧁ āφāĻŽāϰāĻž `"use strict"` āĻŦā§āϝāĻžāĻŦāĻšāĻžāϰ āĻ•āϰ⧇āĻ›āĻŋ, āĻāϟāĻž _āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āĻāϰāϰ_ āϛ⧁āĻā§œā§‡ āĻĻ⧇āĻŦ⧇āĨ¤ āϝāĻĻāĻŋ āφāĻŽāϰāĻž āĻŦā§āϝāĻžāĻŦāĻšāĻžāϰ āύāĻž āĻ•āϰāϤāĻžāĻŽ `"use strict"`, āĻšā§ŸāϤ āĻāϟāĻž āĻ•āĻžāϜ āĻ•āϰāϤ, āϝ⧇āĻšā§‡āϤ⧁ `age` āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋāϟāĻŋ āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āϝ⧁āĻ•ā§āϤ āĻšāϤāĨ¤ + +

+
+ +--- + +###### 21. āϕ⧋āύāϟāĻŋ `sum` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻšāĻŦ⧇? + +```javascript +const sum = eval("10*10+5"); +``` + +- A: `105` +- B: `"105"` +- C: `TypeError` +- D: `"10*10+5"` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +`eval` āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻšāĻŋāϏāĻžāĻŦ⧇ āĻĒāĻžāϏ āĻ•āϰāĻž āϕ⧋āĻĄāϕ⧇ āĻŽā§‚āĻ˛ā§āϝāĻžāϝāĻŧāύ āĻ•āϰ⧇āĨ¤ āϝāĻĻāĻŋ āĻāϟāĻŋ āĻāĻ•āϟāĻŋ āĻ…āĻ­āĻŋāĻŦā§āϝāĻ•ā§āϤāĻŋ (expression) āĻšāϝāĻŧ, āϝ⧇āĻŽāύ āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āĻāϟāĻŋ āĻ…āĻ­āĻŋāĻŦā§āϝāĻ•ā§āϤāĻŋ āĻŽā§‚āĻ˛ā§āϝāĻžāϝāĻŧāύ āĻ•āϰ⧇āϛ⧇āĨ¤ āĻ…āĻ­āĻŋāĻŦā§āϝāĻ•ā§āϤāĻŋāϟāĻŋ āĻšāϞ `10 * 10 + 5`āĨ¤ āĻāϟāĻŋ āĻĢāϞāĻžāĻĢāϞ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `105`āĨ¤ + +

+
+ +--- + +###### 22. āĻ•āϤāĻ•ā§āώāĻŖ cool_secret āĻāĻ•ā§āϏ⧇āϏāϝ⧋āĻ—ā§āϝ? + +```javascript +sessionStorage.setItem("cool_secret", 123); +``` + +- A: Forever, the data doesn't get lost. +- B: When the user closes the tab. +- C: When the user closes the entire browser, not only the tab. +- D: When the user shuts off their computer. + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +āĻŸā§āϝāĻžāĻŦāϟāĻŋ āĻŦāĻ¨ā§āϧ āĻ•āϰāĻžāϰ āĻĒāϰ⧇ `sessionStorage` āϏāĻ‚āϰāĻ•ā§āώāĻŋāϤ āĻĄā§‡āϟāĻž āϏāϰāĻžāύ⧋ āĻšāϝāĻŧāĨ¤ + +āφāĻĒāύāĻŋ `localStorage` āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāϞ⧇, āĻĄā§‡āϟāĻž āϚāĻŋāϰāĻ•āĻžāϞ⧇āϰ āϜāĻ¨ā§āϝ āϏ⧇āĻ–āĻžāύ⧇ āĻĨāĻžāĻ•āĻŦ⧇, āϝāĻĻāĻŋ āύāĻž āωāĻĻāĻžāĻšāϰāĻŖāĻ¸ā§āĻŦāϰ⧂āĻĒ `localStorage.clear()` āĻ•āϞ āĻ•āϰāĻž āĻšāϝāĻŧāĨ¤ + +

+
+ +--- + +###### 23. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +var num = 8; +var num = 10; + +console.log(num); +``` + +- A: `8` +- B: `10` +- C: `SyntaxError` +- D: `ReferenceError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +`var` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĻāĻŋāϝāĻŧ⧇, āφāĻĒāύāĻŋ āĻāĻ•āχ āύāĻžāĻŽā§‡āϰ āĻāĻ•āĻžāϧāĻŋāĻ• āϭ⧇āϰāĻŋāϝāĻŧ⧇āĻŦāϞ āĻ˜ā§‹āώāĻŖāĻž āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āύāĨ¤ āϤāĻžāϰāĻĒāϰ āϭ⧇āϰāĻŋāϝāĻŧ⧇āĻŦāϞāϟāĻŋ āϏāĻ°ā§āĻŦāĻļ⧇āώ āĻŽāĻžāύ āϧāϰ⧇ āϰāĻžāĻ–āĻŦ⧇āĨ¤ + +āĻāϟāĻŋ āĻ•āĻŋāĻ¨ā§āϤ⧁ āφāĻĒāύāĻŋ `let` āĻŦāĻž `const` āĻĻāĻŋāϝāĻŧ⧇ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŦ⧇āύ āύāĻž āϝ⧇āĻšā§‡āϤ⧁ āϏ⧇āϗ⧁āϞāĻŋ āĻŦā§āϞāĻ•-āĻ¸ā§āϕ⧋āĻĒāĻĄ āĻāĻŦāĻ‚ āϏ⧇āχāϜāĻ¨ā§āϝ āĻĒ⧁āύāϰāĻžāϝāĻŧ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰāĻž āϝāĻžāĻŦ⧇ āύāĻžāĨ¤ + +

+
+ +--- + +###### 24. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const obj = { 1: "a", 2: "b", 3: "c" }; +const set = new Set([1, 2, 3, 4, 5]); + +obj.hasOwnProperty("1"); +obj.hasOwnProperty(1); +set.has("1"); +set.has(1); +``` + +- A: `false` `true` `false` `true` +- B: `false` `true` `true` `true` +- C: `true` `true` `false` `true` +- D: `true` `true` `true` `true` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +āϏāĻŽāĻ¸ā§āϤ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āϕ⧀ (āĻĒā§āϰāϤ⧀āĻ•āϗ⧁āϞāĻŋ āĻŦā§āϝāϤ⧀āϤ) āϭ⧇āϤāϰ⧇ āϭ⧇āϤāϰ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚, āĻāĻŽāύāĻ•āĻŋ āφāĻĒāύāĻŋ āύāĻŋāĻœā§‡ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻšāĻŋāϏāĻžāĻŦ⧇ āĻāϟāĻŋāϕ⧇ āύāĻž āϞāĻŋāϖ⧇ āĻĨāĻžāĻ•āϞ⧇āϓ⧎ `obj.hasOwnProperty('1')` āĻ“ āĻāχ āĻ•āĻžāϰāύ⧇āχ `true` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤ + +āĻāĻ•āϟāĻŋ āϏ⧇āĻŸā§‡āϰ āϜāĻ¨ā§āϝ āĻāϟāĻŋ āϏ⧇āĻ­āĻžāĻŦ⧇ āĻ•āĻžāϜ āĻ•āϰ⧇ āύāĻžāĨ¤ āφāĻŽāĻžāĻĻ⧇āϰ āϏ⧇āĻŸā§‡ āϕ⧋āύ `'1'` āύ⧇āχ: `set.has('1')` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `false`āĨ¤ āĻāϟāĻŋāϰ āύāĻŋāωāĻŽā§‡āϰāĻŋāĻ• āϟāĻžāχāĻĒ (āϏāĻ‚āĻ–ā§āϝāĻžāϏ⧂āϚāĻ• āĻĒā§āϰāĻ•āĻžāϰ) āφāϛ⧇ `1`, `set.has(1)` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `true`āĨ¤ + +

+
+ +--- + +###### 25. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const obj = { a: "one", b: "two", a: "three" }; +console.log(obj); +``` + +- A: `{ a: "one", b: "two" }` +- B: `{ b: "two", a: "three" }` +- C: `{ a: "three", b: "two" }` +- D: `SyntaxError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +āφāĻĒāύāĻžāϰ āϝāĻĻāĻŋ āĻāĻ•āχ āύāĻžāĻŽā§‡āϰ āĻĻ⧁āϟāĻŋ āϕ⧀ āĻĨāĻžāϕ⧇ āϤāĻŦ⧇ āϕ⧀āϟāĻŋ āĻĒā§āϰāϤāĻŋāĻ¸ā§āĻĨāĻžāĻĒāύ āĻ•āϰāĻž āĻšāĻŦ⧇āĨ¤ āĻāϟāĻŋ āĻāĻ–āύāĻ“ āϤāĻžāϰ āĻĒā§āϰāĻĨāĻŽ āĻ…āĻŦāĻ¸ā§āĻĨāĻžāύ⧇ āĻĨāĻžāĻ•āĻŦ⧇, āϤāĻŦ⧇ āϏāĻ°ā§āĻŦāĻļ⧇āώ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻ•āϰāĻž āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āϏāĻšāĨ¤ + +

+
+ +--- + +###### 26. āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻāĻ•ā§āϏāĻŋāĻ•āĻŋāωāĻļāύ āĻ•āύāĻŸā§‡āĻ•ā§āϏāϟ āφāĻĒāύāĻžāϰ āϜāĻ¨ā§āϝ āĻĻ⧁āϟāĻŋ āϜāĻŋāύāĻŋāϏ āϤ⧈āϰāĻŋ āĻ•āϰ⧇: āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻāĻŦāĻ‚ "this" āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄāĨ¤ + +- A: true +- B: false +- C: it depends + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +āĻŦ⧇āϏ āĻāĻ•ā§āϏāĻŋāĻ•āĻŋāωāĻļāύ āĻ•āύāĻŸā§‡āĻ•ā§āϏāϟ āĻšāϞ āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻāĻ•ā§āϏāĻŋāĻ•āĻŋāωāĻļāύ āĻ•āύāĻŸā§‡āĻ•ā§āϏāϟ: āĻāϟāĻŋ āφāĻĒāύāĻžāϰ āϕ⧋āĻĄā§‡āϰ āϏāĻ°ā§āĻŦāĻ¤ā§āϰ āĻ…ā§āϝāĻžāĻ•ā§āϏ⧇āϏāϝ⧋āĻ—ā§āϝāĨ¤ + +

+
+ +--- + +###### 27. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +for (let i = 1; i < 5; i++) { + if (i === 3) continue; + console.log(i); +} +``` + +- A: `1` `2` +- B: `1` `2` `3` +- C: `1` `2` `4` +- D: `1` `3` `4` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +`continue` āĻ¸ā§āĻŸā§‡āϟāĻŽā§‡āĻ¨ā§āϟ (āĻŦāĻŋāĻŦ⧃āϤāĻŋ) āĻāĻ•āϟāĻŋ āχāϟāĻžāϰ⧇āĻļāύ (āχāϟāĻžāϰ⧇āĻļāύ) āĻāĻĄāĻŧāĻŋāϝāĻŧ⧇ āϝāĻžāϝāĻŧ āϝāĻĻāĻŋ āĻāĻ•āϟāĻŋ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻļāĻ°ā§āϤ `true` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤ + +

+
+ +--- + +###### 28. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +String.prototype.giveLydiaPizza = () => { + return "Just give Lydia pizza already!"; +}; + +const name = "Lydia"; + +console.log(name.giveLydiaPizza()); +``` + +- A: `"Just give Lydia pizza already!"` +- B: `TypeError: not a function` +- C: `SyntaxError` +- D: `undefined` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +`String` āĻšāϞ āĻāĻ•āϟāĻŋ āĻŦāĻŋāĻ˛ā§āϟ-āχāύ āĻ•āύāĻ¸ā§āĻŸā§āϰāĻžāĻ•ā§āϟāϰ, āϝ⧇āϟāĻŋāϤ⧇ āφāĻŽāϰāĻž āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋ āϗ⧁āϞ⧋ āϝ⧋āĻ— āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ āφāĻŽāĻŋ āĻāϰ āĻĒā§āϰ⧋āĻŸā§‹āϟāĻžāχāĻĒ⧇ āĻāĻ•āϟāĻŋ āĻŽā§‡āĻĨāĻĄ āϝ⧋āĻ— āĻ•āϰ⧇āĻ›āĻŋāĨ¤ āĻĒā§āϰāĻŋāĻŽāĻŋāϟāĻŋāĻ­ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āϗ⧁āϞāĻŋ āĻ¸ā§āĻŦāϝāĻŧāĻ‚āĻ•ā§āϰāĻŋāϝāĻŧāĻ­āĻžāĻŦ⧇ āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āϰ⧂āĻĒāĻžāĻ¨ā§āϤāϰāĻŋāϤ āĻšāϝāĻŧ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻĒā§āϰ⧋āĻŸā§‹āϟāĻžāχāĻĒ āĻĢāĻžāĻ‚āĻļāύ āĻĻā§āĻŦāĻžāϰāĻžāĨ¤ āϏ⧁āϤāϰāĻžāĻ‚, āϏāĻŽāĻ¸ā§āϤ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻāϰ (āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ) āϏ⧇āχ āĻŽā§‡āĻĨāĻĄā§‡āϰ āĻ…ā§āϝāĻžāĻ•ā§āϏ⧇āϏ āφāϛ⧇! + +āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āĻŸā§‡ āĻāϟāĻžāϕ⧇ **āĻĒā§āϰ⧋āĻŸā§‹āϟāĻžāχāĻĒ āχāύāĻšā§‡āϰāĻŋāĻŸā§‡āĻ¨ā§āϏ** āĻŦāϞāĻž āĻšā§ŸāĨ¤ āĻĒā§āϰ⧋āĻŸā§‹āϟāĻžāχāĻĒ āχāύāĻšā§‡āϰāĻŋāĻŸā§‡āĻ¨ā§āϏ āĻšāϞ āĻāĻ•āϟāĻŋ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āϟāĻžāχāĻĒ⧇āϰ (āϝ⧇āĻŽāύ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚) āĻāϰ āϏāĻŽāĻ¸ā§āϤ āχāĻ¨ā§āϏāĻŸā§āϝāĻžāĻ¨ā§āϏāϗ⧁āϞāĻŋāϰ āĻŽāĻ§ā§āϝ⧇ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϏ āĻāĻŦāĻ‚ āĻŽā§‡āĻĨāĻĄāϗ⧁āϞāĻŋ āĻļā§‡ā§ŸāĻžāϰ āĻ•āϰāĻžāϰ āĻāĻ•āϟāĻŋ āωāĻĒāĻžāϝāĻŧ āĻāĻŦāĻ‚ āĻāĻ­āĻžāĻŦ⧇āχ āφāĻĒāύāĻžāϰ āĻĻ⧇āĻ“āϝāĻŧāĻž `giveLydiaPizza` āĻŽā§‡āĻĨāĻĄāϟāĻŋ āφāĻĒāύāĻžāϰ āϤ⧈āϰāĻŋ āĻ•āϰāĻž āĻĒā§āϰāϤāĻŋāϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āϝāĻŧ⧇āϰ āϜāĻ¨ā§āϝ āĻ…ā§āϝāĻžāĻ•ā§āϏ⧇āϏ⧇āĻŦāϞ āĻšāϝāĻŧ⧇ āϝāĻžāϝāĻŧāĨ¤ āĻāϟāĻŋ āĻāĻ•āϝ⧋āϗ⧇ āϏāĻŽāĻ¸ā§āϤ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āϗ⧁āϞāĻŋāϤ⧇ āĻāĻ•āϟāĻŋ āύāϤ⧁āύ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻžāϰ āĻŽāϤ⧋! + +

+
+ +--- + +###### 29. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const a = {}; +const b = { key: "b" }; +const c = { key: "c" }; + +a[b] = 123; +a[c] = 456; + +console.log(a[b]); +``` + +- A: `123` +- B: `456` +- C: `undefined` +- D: `ReferenceError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +Object keys are automatically converted into strings. We are trying to set an object as a key to object `a`, with the value of `123`. + +However, when we stringify an object, it becomes `"[object Object]"`. So what we are saying here, is that `a["[object Object]"] = 123`. Then, we can try to do the same again. `c` is another object that we are implicitly stringifying. So then, `a["[object Object]"] = 456`. + +Then, we log `a[b]`, which is actually `a["[object Object]"]`. We just set that to `456`, so it returns `456`. + +

+
+ +--- + +###### 30. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const foo = () => console.log("First"); +const bar = () => setTimeout(() => console.log("Second")); +const baz = () => console.log("Third"); + +bar(); +foo(); +baz(); +``` + +- A: `First` `Second` `Third` +- B: `First` `Third` `Second` +- C: `Second` `First` `Third` +- D: `Second` `Third` `First` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +We have a `setTimeout` function and invoked it first. Yet, it was logged last. + +This is because in browsers, we don't just have the runtime engine, we also have something called a `WebAPI`. The `WebAPI` gives us the `setTimeout` function to start with, and for example the DOM. + +After the _callback_ is pushed to the WebAPI, the `setTimeout` function itself (but not the callback!) is popped off the stack. + + + +Now, `foo` gets invoked, and `"First"` is being logged. + + + +`foo` is popped off the stack, and `baz` gets invoked. `"Third"` gets logged. + + + +The WebAPI can't just add stuff to the stack whenever it's ready. Instead, it pushes the callback function to something called the _queue_. + + + +This is where an event loop starts to work. An **event loop** looks at the stack and task queue. If the stack is empty, it takes the first thing on the queue and pushes it onto the stack. + + + +`bar` gets invoked, `"Second"` gets logged, and it's popped off the stack. + +

+
+ +--- + +###### 31. What is the event.target when clicking the button? + +```html +
+
+ +
+
+``` + +- A: Outer `div` +- B: Inner `div` +- C: `button` +- D: An array of all nested elements. + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +The deepest nested element that caused the event is the target of the event. You can stop bubbling by `event.stopPropagation` + +

+
+ +--- + +###### 32. When you click the paragraph, what's the logged output? + +```html +
+

Click here!

+
+``` + +- A: `p` `div` +- B: `div` `p` +- C: `p` +- D: `div` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +If we click `p`, we see two logs: `p` and `div`. During event propagation, there are 3 phases: capturing, targeting, and bubbling. By default, event handlers are executed in the bubbling phase (unless you set `useCapture` to `true`). It goes from the deepest nested element outwards. + +

+
+ +--- + +###### 33. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const person = { name: "Lydia" }; + +function sayHi(age) { + return `${this.name} is ${age}`; +} + +console.log(sayHi.call(person, 21)); +console.log(sayHi.bind(person, 21)); +``` + +- A: `undefined is 21` `Lydia is 21` +- B: `function` `function` +- C: `Lydia is 21` `Lydia is 21` +- D: `Lydia is 21` `function` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +With both, we can pass the object to which we want the `this` keyword to refer to. However, `.call` is also _executed immediately_! + +`.bind.` returns a _copy_ of the function, but with a bound context! It is not executed immediately. + +

+
+ +--- + +###### 34. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function sayHi() { + return (() => 0)(); +} + +console.log(typeof sayHi()); +``` + +- A: `"object"` +- B: `"number"` +- C: `"function"` +- D: `"undefined"` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +The `sayHi` function returns the returned value of the immediately invoked function expression (IIFE). This function returned `0`, which is type `"number"`. +FYI: `typeof` can return the following list of values: `undefined`, `boolean`, `number`, `bigint`, `string`, `symbol`, `function` and `object`. Note that `typeof null` returns `"object"`. + +

+
+ +--- + +###### 35. Which of these values are falsy? + +```javascript +0; +new Number(0); +(""); +(" "); +new Boolean(false); +undefined; +``` + +- A: `0`, `''`, `undefined` +- B: `0`, `new Number(0)`, `''`, `new Boolean(false)`, `undefined` +- C: `0`, `''`, `new Boolean(false)`, `undefined` +- D: All of them are falsy + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +There are 8 falsy values: + +- `undefined` +- `null` +- `NaN` +- `false` +- `''` (empty string) +- `0` +- `-0` +- `0n` (BigInt(0)) + +Function constructors, like `new Number` and `new Boolean` are truthy. + +

+
+ +--- + +###### 36. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +console.log(typeof typeof 1); +``` + +- A: `"number"` +- B: `"string"` +- C: `"object"` +- D: `"undefined"` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +`typeof 1` returns `"number"`. +`typeof "number"` returns `"string"` + +

+
+ +--- + +###### 37. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const numbers = [1, 2, 3]; +numbers[10] = 11; +console.log(numbers); +``` + +- A: `[1, 2, 3, null x 7, 11]` +- B: `[1, 2, 3, 11]` +- C: `[1, 2, 3, empty x 7, 11]` +- D: `SyntaxError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +When you set a value to an element in an array that exceeds the length of the array, JavaScript creates something called "empty slots". These actually have the value of `undefined`, but you will see something like: + +`[1, 2, 3, empty x 7, 11]` + +depending on where you run it (it's different for every browser, node, etc.) + +

+
+ +--- + +###### 38. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +(() => { + let x, y; + try { + throw new Error(); + } catch (x) { + (x = 1), (y = 2); + console.log(x); + } + console.log(x); + console.log(y); +})(); +``` + +- A: `1` `undefined` `2` +- B: `undefined` `undefined` `undefined` +- C: `1` `1` `2` +- D: `1` `undefined` `undefined` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +The `catch` block receives the argument `x`. This is not the same `x` as the variable when we pass arguments. This variable `x` is block-scoped. + +Later, we set this block-scoped variable equal to `1`, and set the value of the variable `y`. Now, we log the block-scoped variable `x`, which is equal to `1`. + +Outside of the `catch` block, `x` is still `undefined`, and `y` is `2`. When we want to `console.log(x)` outside of the `catch` block, it returns `undefined`, and `y` returns `2`. + +

+
+ +--- + +###### 39. Everything in JavaScript is either a... + +- A: primitive or object +- B: function or object +- C: trick question! only objects +- D: number or object + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +JavaScript only has primitive types and objects. + +Primitive types are `boolean`, `null`, `undefined`, `bigint`, `number`, `string`, and `symbol`. + +What differentiates a primitive from an object is that primitives do not have any properties or methods; however, you'll note that `'foo'.toUpperCase()` evaluates to `'FOO'` and does not result in a `TypeError`. This is because when you try to access a property or method on a primitive like a string, JavaScript will implicitly wrap the primitive type using one of the wrapper classes, i.e. `String`, and then immediately discard the wrapper after the expression evaluates. All primitives except for `null` and `undefined` exhibit this behavior. + +

+
+ +--- + +###### 40. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +[ + [0, 1], + [2, 3], +].reduce( + (acc, cur) => { + return acc.concat(cur); + }, + [1, 2] +); +``` + +- A: `[0, 1, 2, 3, 1, 2]` +- B: `[6, 1, 2]` +- C: `[1, 2, 0, 1, 2, 3]` +- D: `[1, 2, 6]` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +`[1, 2]` is our initial value. This is the value we start with, and the value of the very first `acc`. During the first round, `acc` is `[1,2]`, and `cur` is `[0, 1]`. We concatenate them, which results in `[1, 2, 0, 1]`. + +Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and get `[1, 2, 0, 1, 2, 3]` + +

+
+ +--- + +###### 41. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +!!null; +!!""; +!!1; +``` + +- A: `false` `true` `false` +- B: `false` `false` `true` +- C: `false` `true` `true` +- D: `true` `true` `false` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +`null` is falsy. `!null` returns `true`. `!true` returns `false`. + +`""` is falsy. `!""` returns `true`. `!true` returns `false`. + +`1` is truthy. `!1` returns `false`. `!false` returns `true`. + +

+
+ +--- + +###### 42. What does the `setInterval` method return in the browser? + +```javascript +setInterval(() => console.log("Hi"), 1000); +``` + +- A: a unique id +- B: the amount of milliseconds specified +- C: the passed function +- D: `undefined` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +It returns a unique id. This id can be used to clear that interval with the `clearInterval()` function. + +

+
+ +--- + +###### 43. What does this return? + +```javascript +[..."Lydia"]; +``` + +- A: `["L", "y", "d", "i", "a"]` +- B: `["Lydia"]` +- C: `[[], "Lydia"]` +- D: `[["L", "y", "d", "i", "a"]]` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +A string is an iterable. The spread operator maps every character of an iterable to one element. + +

+
+ +--- + +###### 44. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function* generator(i) { + yield i; + yield i * 2; +} + +const gen = generator(10); + +console.log(gen.next().value); +console.log(gen.next().value); +``` + +- A: `[0, 10], [10, 20]` +- B: `20, 20` +- C: `10, 20` +- D: `0, 10 and 10, 20` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +Regular functions cannot be stopped mid-way after invocation. However, a generator function can be "stopped" midway, and later continue from where it stopped. Every time a generator function encounters a `yield` keyword, the function yields the value specified after it. Note that the generator function in that case doesn’t _return_ the value, it _yields_ the value. + +First, we initialize the generator function with `i` equal to `10`. We invoke the generator function using the `next()` method. The first time we invoke the generator function, `i` is equal to `10`. It encounters the first `yield` keyword: it yields the value of `i`. The generator is now "paused", and `10` gets logged. + +Then, we invoke the function again with the `next()` method. It starts to continue where it stopped previously, still with `i` equal to `10`. Now, it encounters the next `yield` keyword, and yields `i * 2`. `i` is equal to `10`, so it returns `10 * 2`, which is `20`. This results in `10, 20`. + +

+
+ +--- + +###### 45. What does this return? + +```javascript +const firstPromise = new Promise((res, rej) => { + setTimeout(res, 500, "one"); +}); + +const secondPromise = new Promise((res, rej) => { + setTimeout(res, 100, "two"); +}); + +Promise.race([firstPromise, secondPromise]).then((res) => console.log(res)); +``` + +- A: `"one"` +- B: `"two"` +- C: `"two" "one"` +- D: `"one" "two"` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +When we pass multiple promises to the `Promise.race` method, it resolves/rejects the _first_ promise that resolves/rejects. To the `setTimeout` method, we pass a timer: 500ms for the first promise (`firstPromise`), and 100ms for the second promise (`secondPromise`). This means that the `secondPromise` resolves first with the value of `'two'`. `res` now holds the value of `'two'`, which gets logged. + +

+
+ +--- + +###### 46. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +let person = { name: "Lydia" }; +const members = [person]; +person = null; + +console.log(members); +``` + +- A: `null` +- B: `[null]` +- C: `[{}]` +- D: `[{ name: "Lydia" }]` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +First, we declare a variable `person` with the value of an object that has a `name` property. + + + +Then, we declare a variable called `members`. We set the first element of that array equal to the value of the `person` variable. Objects interact by _reference_ when setting them equal to each other. When you assign a reference from one variable to another, you make a _copy_ of that reference. (note that they don't have the _same_ reference!) + + + +Then, we set the variable `person` equal to `null`. + + + +We are only modifying the value of the `person` variable, and not the first element in the array, since that element has a different (copied) reference to the object. The first element in `members` still holds its reference to the original object. When we log the `members` array, the first element still holds the value of the object, which gets logged. + +

+
+ +--- + +###### 47. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const person = { + name: "Lydia", + age: 21, +}; + +for (const item in person) { + console.log(item); +} +``` + +- A: `{ name: "Lydia" }, { age: 21 }` +- B: `"name", "age"` +- C: `"Lydia", 21` +- D: `["name", "Lydia"], ["age", 21]` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +With a `for-in` loop, we can iterate through object keys, in this case `name` and `age`. Under the hood, object keys are strings (if they're not a Symbol). On every loop, we set the value of `item` equal to the current key it’s iterating over. First, `item` is equal to `name`, and gets logged. Then, `item` is equal to `age`, which gets logged. + +

+
+ +--- + +###### 48. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +console.log(3 + 4 + "5"); +``` + +- A: `"345"` +- B: `"75"` +- C: `12` +- D: `"12"` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +Operator associativity is the order in which the compiler evaluates the expressions, either left-to-right or right-to-left. This only happens if all operators have the _same_ precedence. We only have one type of operator: `+`. For addition, the associativity is left-to-right. + +`3 + 4` gets evaluated first. This results in the number `7`. + +`7 + '5'` results in `"75"` because of coercion. JavaScript converts the number `7` into a string, see question 15. We can concatenate two strings using the `+`operator. `"7" + "5"` results in `"75"`. + +

+
+ +--- + +###### 49. What's the value of `num`? + +```javascript +const num = parseInt("7*6", 10); +``` + +- A: `42` +- B: `"42"` +- C: `7` +- D: `NaN` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +Only the first number in the string is returned. Based on the _radix_ (the second argument in order to specify what type of number we want to parse it to: base 10, hexadecimal, octal, binary, etc.), the `parseInt` checks whether the characters in the string are valid. Once it encounters a character that isn't a valid number in the radix, it stops parsing and ignores the following characters. + +`*` is not a valid number. It only parses `"7"` into the decimal `7`. `num` now holds the value of `7`. + +

+
+ +--- + +###### 50. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +[1, 2, 3].map((num) => { + if (typeof num === "number") return; + return num * 2; +}); +``` + +- A: `[]` +- B: `[null, null, null]` +- C: `[undefined, undefined, undefined]` +- D: `[ 3 x empty ]` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +When mapping over the array, the value of `num` is equal to the element it’s currently looping over. In this case, the elements are numbers, so the condition of the if statement `typeof num === "number"` returns `true`. The map function creates a new array and inserts the values returned from the function. + +However, we don’t return a value. When we don’t return a value from the function, the function returns `undefined`. For every element in the array, the function block gets called, so for each element we return `undefined`. + +

+
+ +--- + +###### 51. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function getInfo(member, year) { + member.name = "Lydia"; + year = "1998"; +} + +const person = { name: "Sarah" }; +const birthYear = "1997"; + +getInfo(person, birthYear); + +console.log(person, birthYear); +``` + +- A: `{ name: "Lydia" }, "1997"` +- B: `{ name: "Sarah" }, "1998"` +- C: `{ name: "Lydia" }, "1998"` +- D: `{ name: "Sarah" }, "1997"` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +Arguments are passed by _value_, unless their value is an object, then they're passed by _reference_. `birthYear` is passed by value, since it's a string, not an object. When we pass arguments by value, a _copy_ of that value is created (see question 46). + +The variable `birthYear` has a reference to the value `"1997"`. The argument `year` also has a reference to the value `"1997"`, but it's not the same value as `birthYear` has a reference to. When we update the value of `year` by setting `year` equal to `"1998"`, we are only updating the value of `year`. `birthYear` is still equal to `"1997"`. + +The value of `person` is an object. The argument `member` has a (copied) reference to the _same_ object. When we modify a property of the object `member` has a reference to, the value of `person` will also be modified, since they both have a reference to the same object. `person`'s `name` property is now equal to the value `"Lydia"` + +

+
+ +--- + +###### 52. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function greeting() { + throw "Hello world!"; +} + +function sayHi() { + try { + const data = greeting(); + console.log("It worked!", data); + } catch (e) { + console.log("Oh no an error:", e); + } +} + +sayHi(); +``` + +- A: `It worked! Hello world!` +- B: `Oh no an error: undefined` +- C: `SyntaxError: can only throw Error objects` +- D: `Oh no an error: Hello world!` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +With the `throw` statement, we can create custom errors. With this statement, you can throw exceptions. An exception can be a string, a number, a boolean or an object. In this case, our exception is the string `'Hello world!'`. + +With the `catch` statement, we can specify what to do if an exception is thrown in the `try` block. An exception is thrown: the string `'Hello world!'`. `e` is now equal to that string, which we log. This results in `'Oh an error: Hello world!'`. + +

+
+ +--- + +###### 53. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function Car() { + this.make = "Lamborghini"; + return { make: "Maserati" }; +} + +const myCar = new Car(); +console.log(myCar.make); +``` + +- A: `"Lamborghini"` +- B: `"Maserati"` +- C: `ReferenceError` +- D: `TypeError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +When a constructor function is called with the `new` keyword, it creates an object and sets the `this` keyword to refer to that object. By default, if the constructor function doesn't explicitly return anything, it will return the newly created object. + +In this case, the constructor function `Car` explicitly returns a new object with `make` set to `"Maserati"`, which overrides the default behavior. Therefore, when `new Car()` is called, the _returned_ object is assigned to `myCar`, resulting in the output being `"Maserati"` when `myCar.make` is accessed. + +

+
+ +--- + +###### 54. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +(() => { + let x = (y = 10); +})(); + +console.log(typeof x); +console.log(typeof y); +``` + +- A: `"undefined", "number"` +- B: `"number", "number"` +- C: `"object", "number"` +- D: `"number", "undefined"` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +`let x = (y = 10);` is actually shorthand for: + +```javascript +y = 10; +let x = y; +``` + +When we set `y` equal to `10`, we actually add a property `y` to the global object (`window` in the browser, `global` in Node). In a browser, `window.y` is now equal to `10`. + +Then, we declare a variable `x` with the value of `y`, which is `10`. Variables declared with the `let` keyword are _block scoped_, they are only defined within the block they're declared in; the immediately invoked function expression (IIFE) in this case. When we use the `typeof` operator, the operand `x` is not defined: we are trying to access `x` outside of the block it's declared in. This means that `x` is not defined. Values who haven't been assigned a value or declared are of type `"undefined"`. `console.log(typeof x)` returns `"undefined"`. + +However, we created a global variable `y` when setting `y` equal to `10`. This value is accessible anywhere in our code. `y` is defined, and holds a value of type `"number"`. `console.log(typeof y)` returns `"number"`. + +

+
+ +--- + +###### 55. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +class Dog { + constructor(name) { + this.name = name; + } +} + +Dog.prototype.bark = function () { + console.log(`Woof I am ${this.name}`); +}; + +const pet = new Dog("Mara"); + +pet.bark(); + +delete Dog.prototype.bark; + +pet.bark(); +``` + +- A: `"Woof I am Mara"`, `TypeError` +- B: `"Woof I am Mara"`, `"Woof I am Mara"` +- C: `"Woof I am Mara"`, `undefined` +- D: `TypeError`, `TypeError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +We can delete properties from objects using the `delete` keyword, also on the prototype. By deleting a property on the prototype, it is not available anymore in the prototype chain. In this case, the `bark` function is not available anymore on the prototype after `delete Dog.prototype.bark`, yet we still try to access it. + +When we try to invoke something that is not a function, a `TypeError` is thrown. In this case `TypeError: pet.bark is not a function`, since `pet.bark` is `undefined`. + +

+
+ +--- + +###### 56. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const set = new Set([1, 1, 2, 3, 4]); + +console.log(set); +``` + +- A: `[1, 1, 2, 3, 4]` +- B: `[1, 2, 3, 4]` +- C: `{1, 1, 2, 3, 4}` +- D: `{1, 2, 3, 4}` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +The `Set` object is a collection of _unique_ values: a value can only occur once in a set. + +We passed the iterable `[1, 1, 2, 3, 4]` with a duplicate value `1`. Since we cannot have two of the same values in a set, one of them is removed. This results in `{1, 2, 3, 4}`. + +

+
+ +--- + +###### 57. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +// counter.js +let counter = 10; +export default counter; +``` + +```javascript +// index.js +import myCounter from "./counter"; + +myCounter += 1; + +console.log(myCounter); +``` + +- A: `10` +- B: `11` +- C: `Error` +- D: `NaN` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +An imported module is _read-only_: you cannot modify the imported module. Only the module that exports them can change its value. + +When we try to increment the value of `myCounter`, it throws an error: `myCounter` is read-only and cannot be modified. + +

+
+ +--- + +###### 58. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const name = "Lydia"; +age = 21; + +console.log(delete name); +console.log(delete age); +``` + +- A: `false`, `true` +- B: `"Lydia"`, `21` +- C: `true`, `true` +- D: `undefined`, `undefined` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +The `delete` operator returns a boolean value: `true` on a successful deletion, else it'll return `false`. However, variables declared with the `var`, `const`, or `let` keywords cannot be deleted using the `delete` operator. + +The `name` variable was declared with a `const` keyword, so its deletion is not successful: `false` is returned. When we set `age` equal to `21`, we actually added a property called `age` to the global object. You can successfully delete properties from objects this way, also the global object, so `delete age` returns `true`. + +

+
+ +--- + +###### 59. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const numbers = [1, 2, 3, 4, 5]; +const [y] = numbers; + +console.log(y); +``` + +- A: `[[1, 2, 3, 4, 5]]` +- B: `[1, 2, 3, 4, 5]` +- C: `1` +- D: `[1]` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +We can unpack values from arrays or properties from objects through destructuring. For example: + +```javascript +[a, b] = [1, 2]; +``` + + + +The value of `a` is now `1`, and the value of `b` is now `2`. What we actually did in the question, is: + +```javascript +[y] = [1, 2, 3, 4, 5]; +``` + + + +This means that the value of `y` is equal to the first value in the array, which is the number `1`. When we log `y`, `1` is returned. + +

+
+ +--- + +###### 60. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const user = { name: "Lydia", age: 21 }; +const admin = { admin: true, ...user }; + +console.log(admin); +``` + +- A: `{ admin: true, user: { name: "Lydia", age: 21 } }` +- B: `{ admin: true, name: "Lydia", age: 21 }` +- C: `{ admin: true, user: ["Lydia", 21] }` +- D: `{ admin: true }` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +It's possible to combine objects using the spread operator `...`. It lets you create copies of the key/value pairs of one object, and add them to another object. In this case, we create copies of the `user` object, and add them to the `admin` object. The `admin` object now contains the copied key/value pairs, which results in `{ admin: true, name: "Lydia", age: 21 }`. + +

+
+ +--- + +###### 61. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const person = { name: "Lydia" }; + +Object.defineProperty(person, "age", { value: 21 }); + +console.log(person); +console.log(Object.keys(person)); +``` + +- A: `{ name: "Lydia", age: 21 }`, `["name", "age"]` +- B: `{ name: "Lydia", age: 21 }`, `["name"]` +- C: `{ name: "Lydia"}`, `["name", "age"]` +- D: `{ name: "Lydia"}`, `["age"]` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +With the `defineProperty` method, we can add new properties to an object, or modify existing ones. When we add a property to an object using the `defineProperty` method, they are by default _not enumerable_. The `Object.keys` method returns all _enumerable_ property names from an object, in this case only `"name"`. + +Properties added using the `defineProperty` method are immutable by default. You can override this behavior using the `writable`, `configurable` and `enumerable` properties. This way, the `defineProperty` method gives you a lot more control over the properties you're adding to an object. + +

+
+ +--- + +###### 62. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const settings = { + username: "lydiahallie", + level: 19, + health: 90, +}; + +const data = JSON.stringify(settings, ["level", "health"]); +console.log(data); +``` + +- A: `"{"level":19, "health":90}"` +- B: `"{"username": "lydiahallie"}"` +- C: `"["level", "health"]"` +- D: `"{"username": "lydiahallie", "level":19, "health":90}"` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +The second argument of `JSON.stringify` is the _replacer_. The replacer can either be a function or an array, and lets you control what and how the values should be stringified. + +If the replacer is an _array_, only the property names included in the array will be added to the JSON string. In this case, only the properties with the names `"level"` and `"health"` are included, `"username"` is excluded. `data` is now equal to `"{"level":19, "health":90}"`. + +If the replacer is a _function_, this function gets called on every property in the object you're stringifying. The value returned from this function will be the value of the property when it's added to the JSON string. If the value is `undefined`, this property is excluded from the JSON string. + +

+
+ +--- + +###### 63. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +let num = 10; + +const increaseNumber = () => num++; +const increasePassedNumber = (number) => number++; + +const num1 = increaseNumber(); +const num2 = increasePassedNumber(num1); + +console.log(num1); +console.log(num2); +``` + +- A: `10`, `10` +- B: `10`, `11` +- C: `11`, `11` +- D: `11`, `12` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +The unary operator `++` _first returns_ the value of the operand, _then increments_ the value of the operand. The value of `num1` is `10`, since the `increaseNumber` function first returns the value of `num`, which is `10`, and only increments the value of `num` afterward. + +`num2` is `10`, since we passed `num1` to the `increasePassedNumber`. `number` is equal to `10`(the value of `num1`). Again, the unary operator `++` _first returns_ the value of the operand, _then increments_ the value of the operand. The value of `number` is `10`, so `num2` is equal to `10`. + +

+
+ +--- + +###### 64. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const value = { number: 10 }; + +const multiply = (x = { ...value }) => { + console.log((x.number *= 2)); +}; + +multiply(); +multiply(); +multiply(value); +multiply(value); +``` + +- A: `20`, `40`, `80`, `160` +- B: `20`, `40`, `20`, `40` +- C: `20`, `20`, `20`, `40` +- D: `NaN`, `NaN`, `20`, `40` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +In ES6, we can initialize parameters with a default value. The value of the parameter will be the default value, if no other value has been passed to the function, or if the value of the parameter is `"undefined"`. In this case, we spread the properties of the `value` object into a new object, so `x` has the default value of `{ number: 10 }`. + +The default argument is evaluated at _call time_! Every time we call the function, a _new_ object is created. We invoke the `multiply` function the first two times without passing a value: `x` has the default value of `{ number: 10 }`. We then log the multiplied value of that number, which is `20`. + +The third time we invoke multiply, we do pass an argument: the object called `value`. The `*=` operator is actually shorthand for `x.number = x.number * 2`: we modify the value of `x.number`, and log the multiplied value `20`. + +The fourth time, we pass the `value` object again. `x.number` was previously modified to `20`, so `x.number *= 2` logs `40`. + +

+
+ +--- + +###### 65. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +[1, 2, 3, 4].reduce((x, y) => console.log(x, y)); +``` + +- A: `1` `2` and `3` `3` and `6` `4` +- B: `1` `2` and `2` `3` and `3` `4` +- C: `1` `undefined` and `2` `undefined` and `3` `undefined` and `4` `undefined` +- D: `1` `2` and `undefined` `3` and `undefined` `4` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +The first argument that the `reduce` method receives is the _accumulator_, `x` in this case. The second argument is the _current value_, `y`. With the reduce method, we execute a callback function on every element in the array, which could ultimately result in one single value. + +In this example, we are not returning any values, we are simply logging the values of the accumulator and the current value. + +The value of the accumulator is equal to the previously returned value of the callback function. If you don't pass the optional `initialValue` argument to the `reduce` method, the accumulator is equal to the first element on the first call. + +On the first call, the accumulator (`x`) is `1`, and the current value (`y`) is `2`. We don't return from the callback function, we log the accumulator, and the current values: `1` and `2` get logged. + +If you don't return a value from a function, it returns `undefined`. On the next call, the accumulator is `undefined`, and the current value is `3`. `undefined` and `3` get logged. + +On the fourth call, we again don't return from the callback function. The accumulator is again `undefined`, and the current value is `4`. `undefined` and `4` get logged. + +

+
+ +--- + +###### 66. With which constructor can we successfully extend the `Dog` class? + +```javascript +class Dog { + constructor(name) { + this.name = name; + } +}; + +class Labrador extends Dog { + // 1 + constructor(name, size) { + this.size = size; + } + // 2 + constructor(name, size) { + super(name); + this.size = size; + } + // 3 + constructor(size) { + super(name); + this.size = size; + } + // 4 + constructor(name, size) { + this.name = name; + this.size = size; + } + +}; +``` + +- A: 1 +- B: 2 +- C: 3 +- D: 4 + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +In a derived class, you cannot access the `this` keyword before calling `super`. If you try to do that, it will throw a ReferenceError: 1 and 4 would throw a reference error. + +With the `super` keyword, we call that parent class's constructor with the given arguments. The parent's constructor receives the `name` argument, so we need to pass `name` to `super`. + +The `Labrador` class receives two arguments, `name` since it extends `Dog`, and `size` as an extra property on the `Labrador` class. They both need to be passed to the constructor function on `Labrador`, which is done correctly using constructor 2. + +

+
+ +--- + +###### 67. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +// index.js +console.log("running index.js"); +import { sum } from "./sum.js"; +console.log(sum(1, 2)); + +// sum.js +console.log("running sum.js"); +export const sum = (a, b) => a + b; +``` + +- A: `running index.js`, `running sum.js`, `3` +- B: `running sum.js`, `running index.js`, `3` +- C: `running sum.js`, `3`, `running index.js` +- D: `running index.js`, `undefined`, `running sum.js` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +With the `import` keyword, all imported modules are _pre-parsed_. This means that the imported modules get run _first_, and the code in the file that imports the module gets executed _after_. + +This is a difference between `require()` in CommonJS and `import`! With `require()`, you can load dependencies on demand while the code is being run. If we had used `require` instead of `import`, `running index.js`, `running sum.js`, `3` would have been logged to the console. + +

+
+ +--- + +###### 68. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +console.log(Number(2) === Number(2)); +console.log(Boolean(false) === Boolean(false)); +console.log(Symbol("foo") === Symbol("foo")); +``` + +- A: `true`, `true`, `false` +- B: `false`, `true`, `false` +- C: `true`, `false`, `true` +- D: `true`, `true`, `true` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +Every Symbol is entirely unique. The purpose of the argument passed to the Symbol is to give the Symbol a description. The value of the Symbol is not dependent on the passed argument. As we test equality, we are creating two entirely new symbols: the first `Symbol('foo')`, and the second `Symbol('foo')`. These two values are unique and not equal to each other, `Symbol('foo') === Symbol('foo')` returns `false`. + +

+
+ +--- + +###### 69. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const name = "Lydia Hallie"; +console.log(name.padStart(13)); +console.log(name.padStart(2)); +``` + +- A: `"Lydia Hallie"`, `"Lydia Hallie"` +- B: `" Lydia Hallie"`, `" Lydia Hallie"` (`"[13x whitespace]Lydia Hallie"`, `"[2x whitespace]Lydia Hallie"`) +- C: `" Lydia Hallie"`, `"Lydia Hallie"` (`"[1x whitespace]Lydia Hallie"`, `"Lydia Hallie"`) +- D: `"Lydia Hallie"`, `"Lyd"`, + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +With the `padStart` method, we can add padding to the beginning of a string. The value passed to this method is the _total_ length of the string together with the padding. The string `"Lydia Hallie"` has a length of `12`. `name.padStart(13)` inserts 1 space at the start of the string, because 12 + 1 is 13. + +If the argument passed to the `padStart` method is smaller than the length of the array, no padding will be added. + +

+
+ +--- + +###### 70. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +console.log("đŸĨ‘" + "đŸ’ģ"); +``` + +- A: `"đŸĨ‘đŸ’ģ"` +- B: `257548` +- C: A string containing their code points +- D: Error + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +With the `+` operator, you can concatenate strings. In this case, we are concatenating the string `"đŸĨ‘"` with the string `"đŸ’ģ"`, resulting in `"đŸĨ‘đŸ’ģ"`. + +

+
+ +--- + +###### 71. How can we log the values that are commented out after the console.log statement? + +```javascript +function* startGame() { + const āωāĻ¤ā§āϤāϰ = yield "Do you love JavaScript?"; + if (āωāĻ¤ā§āϤāϰ !== "Yes") { + return "Oh wow... Guess we're done here"; + } + return "JavaScript loves you back â¤ī¸"; +} + +const game = startGame(); +console.log(/* 1 */); // Do you love JavaScript? +console.log(/* 2 */); // JavaScript loves you back â¤ī¸ +``` + +- A: `game.next("Yes").value` and `game.next().value` +- B: `game.next.value("Yes")` and `game.next.value()` +- C: `game.next().value` and `game.next("Yes").value` +- D: `game.next.value()` and `game.next.value("Yes")` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +A generator function "pauses" its execution when it sees the `yield` keyword. First, we have to let the function yield the string "Do you love JavaScript?", which can be done by calling `game.next().value`. + +Every line is executed, until it finds the first `yield` keyword. There is a `yield` keyword on the first line within the function: the execution stops with the first yield! _This means that the variable `āωāĻ¤ā§āϤāϰ` is not defined yet!_ + +When we call `game.next("Yes").value`, the previous `yield` is replaced with the value of the parameters passed to the `next()` function, `"Yes"` in this case. The value of the variable `āωāĻ¤ā§āϤāϰ` is now equal to `"Yes"`. The condition of the if-statement returns `false`, and `JavaScript loves you back â¤ī¸` gets logged. + +

+
+ +--- + +###### 72. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +console.log(String.raw`Hello\nworld`); +``` + +- A: `Hello world!` +- B: `Hello`
     `world` +- C: `Hello\nworld` +- D: `Hello\n`
     `world` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +`String.raw` returns a string where the escapes (`\n`, `\v`, `\t` etc.) are ignored! Backslashes can be an issue since you could end up with something like: + +`` const path = `C:\Documents\Projects\table.html` `` + +Which would result in: + +`"C:DocumentsProjects able.html"` + +With `String.raw`, it would simply ignore the escape and print: + +`C:\Documents\Projects\table.html` + +In this case, the string is `Hello\nworld`, which gets logged. + +

+
+ +--- + +###### 73. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +async function getData() { + return await Promise.resolve("I made it!"); +} + +const data = getData(); +console.log(data); +``` + +- A: `"I made it!"` +- B: `Promise {: "I made it!"}` +- C: `Promise {}` +- D: `undefined` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +An async function always returns a promise. The `await` still has to wait for the promise to resolve: a pending promise gets returned when we call `getData()` in order to set `data` equal to it. + +If we wanted to get access to the resolved value `"I made it"`, we could have used the `.then()` method on `data`: + +`data.then(res => console.log(res))` + +This would've logged `"I made it!"` + +

+
+ +--- + +###### 74. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function addToList(item, list) { + return list.push(item); +} + +const result = addToList("apple", ["banana"]); +console.log(result); +``` + +- A: `['apple', 'banana']` +- B: `2` +- C: `true` +- D: `undefined` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +The `.push()` method returns the _length_ of the new array! Previously, the array contained one element (the string `"banana"`) and had a length of `1`. After adding the string `"apple"` to the array, the array contains two elements, and has a length of `2`. This gets returned from the `addToList` function. + +The `push` method modifies the original array. If you wanted to return the _array_ from the function rather than the _length of the array_, you should have returned `list` after pushing `item` to it. + +

+
+ +--- + +###### 75. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const box = { x: 10, y: 20 }; + +Object.freeze(box); + +const shape = box; +shape.x = 100; + +console.log(shape); +``` + +- A: `{ x: 100, y: 20 }` +- B: `{ x: 10, y: 20 }` +- C: `{ x: 100 }` +- D: `ReferenceError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +`Object.freeze` makes it impossible to add, remove, or modify properties of an object (unless the property's value is another object). + +When we create the variable `shape` and set it equal to the frozen object `box`, `shape` also refers to a frozen object. You can check whether an object is frozen by using `Object.isFrozen`. In this case, `Object.isFrozen(shape)` would return true, since the variable `shape` has a reference to a frozen object. + +Since `shape` is frozen, and since the value of `x` is not an object, we cannot modify the property `x`. `x` is still equal to `10`, and `{ x: 10, y: 20 }` gets logged. + +

+
+ +--- + +###### 76. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const { firstName: myName } = { firstName: "Lydia" }; + +console.log(firstName); +``` + +- A: `"Lydia"` +- B: `"myName"` +- C: `undefined` +- D: `ReferenceError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +By using [destructuring assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) syntax we can unpack values from arrays, or properties from objects, into distinct variables: + +```javascript +const { firstName } = { firstName: "Lydia" }; +// ES5 version: +// var firstName = { firstName: 'Lydia' }.firstName; + +console.log(firstName); // "Lydia" +``` + +Also, a property can be unpacked from an object and assigned to a variable with a different name than the object property: + +```javascript +const { firstName: myName } = { firstName: "Lydia" }; +// ES5 version: +// var myName = { firstName: 'Lydia' }.firstName; + +console.log(myName); // "Lydia" +console.log(firstName); // Uncaught ReferenceError: firstName is not defined +``` + +Therefore, `firstName` does not exist as a variable, thus attempting to access its value will raise a `ReferenceError`. + +**Note:** Be aware of the `global scope` properties: + +```javascript +const { name: myName } = { name: "Lydia" }; + +console.log(myName); // "lydia" +console.log(name); // "" ----- Browser e.g. Chrome +console.log(name); // ReferenceError: name is not defined ----- NodeJS +``` + +Whenever Javascript is unable to find a variable within the _current scope_, it climbs up the [Scope chain](https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch3.md) and searches for it and if it reaches the top-level scope, aka **Global scope**, and still doesn't find it, it will throw a `ReferenceError`. + +- In **Browsers** such as _Chrome_, `name` is a _deprecated global scope property_. In this example, the code is running inside _global scope_ and there is no user-defined local variable for `name`, therefore it searches the predefined _variables/properties_ in the global scope which is in the case of browsers, it searches through `window` object and it will extract the [window.name](https://developer.mozilla.org/en-US/docs/Web/API/Window/name) value which is equal to an **empty string**. + +- In **NodeJS**, there is no such property on the `global` object, thus attempting to access a non-existent variable will raise a [ReferenceError](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_defined). + +

+
+ +--- + +###### 77. Is this a pure function? + +```javascript +function sum(a, b) { + return a + b; +} +``` + +- A: Yes +- B: No + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +A pure function is a function that _always_ returns the same result, if the same arguments are passed. + +The `sum` function always returns the same result. If we pass `1` and `2`, it will _always_ return `3` without side effects. If we pass `5` and `10`, it will _always_ return `15`, and so on. This is the definition of a pure function. + +

+
+ +--- + +###### 78. What is the output? + +```javascript +const add = () => { + const cache = {}; + return (num) => { + if (num in cache) { + return `From cache! ${cache[num]}`; + } else { + const result = num + 10; + cache[num] = result; + return `Calculated! ${result}`; + } + }; +}; + +const addFunction = add(); +console.log(addFunction(10)); +console.log(addFunction(10)); +console.log(addFunction(5 * 2)); +``` + +- A: `Calculated! 20` `Calculated! 20` `Calculated! 20` +- B: `Calculated! 20` `From cache! 20` `Calculated! 20` +- C: `Calculated! 20` `From cache! 20` `From cache! 20` +- D: `Calculated! 20` `From cache! 20` `Error` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +The `add` function is a _memoized_ function. With memoization, we can cache the results of a function in order to speed up its execution. In this case, we create a `cache` object that stores the previously returned values. + +If we call the `addFunction` function again with the same argument, it first checks whether it has already gotten that value in its cache. If that's the case, the cache value will be returned, which saves execution time. Otherwise, if it's not cached, it will calculate the value and store it afterward. + +We call the `addFunction` function three times with the same value: on the first invocation, the value of the function when `num` is equal to `10` isn't cached yet. The condition of the if-statement `num in cache` returns `false`, and the else block gets executed: `Calculated! 20` gets logged, and the value of the result gets added to the cache object. `cache` now looks like `{ 10: 20 }`. + +The second time, the `cache` object contains the value that gets returned for `10`. The condition of the if-statement `num in cache` returns `true`, and `'From cache! 20'` gets logged. + +The third time, we pass `5 * 2` to the function which gets evaluated to `10`. The `cache` object contains the value that gets returned for `10`. The condition of the if-statement `num in cache` returns `true`, and `'From cache! 20'` gets logged. + +

+
+ +--- + +###### 79. What is the output? + +```javascript +const myLifeSummedUp = ["☕", "đŸ’ģ", "🍷", "đŸĢ"]; + +for (let item in myLifeSummedUp) { + console.log(item); +} + +for (let item of myLifeSummedUp) { + console.log(item); +} +``` + +- A: `0` `1` `2` `3` and `"☕"` `"đŸ’ģ"` `"🍷"` `"đŸĢ"` +- B: `"☕"` `"đŸ’ģ"` `"🍷"` `"đŸĢ"` and `"☕"` `"đŸ’ģ"` `"🍷"` `"đŸĢ"` +- C: `"☕"` `"đŸ’ģ"` `"🍷"` `"đŸĢ"` and `0` `1` `2` `3` +- D: `0` `1` `2` `3` and `{0: "☕", 1: "đŸ’ģ", 2: "🍷", 3: "đŸĢ"}` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +With a _for-in_ loop, we can iterate over **enumerable** properties. In an array, the enumerable properties are the "keys" of array elements, which are actually their indexes. You could see an array as: + +`{0: "☕", 1: "đŸ’ģ", 2: "🍷", 3: "đŸĢ"}` + +Where the keys are the enumerable properties. `0` `1` `2` `3` get logged. + +With a _for-of_ loop, we can iterate over **iterables**. An array is an iterable. When we iterate over the array, the variable "item" is equal to the element it's currently iterating over, `"☕"` `"đŸ’ģ"` `"🍷"` `"đŸĢ"` get logged. + +

+
+ +--- + +###### 80. What is the output? + +```javascript +const list = [1 + 2, 1 * 2, 1 / 2]; +console.log(list); +``` + +- A: `["1 + 2", "1 * 2", "1 / 2"]` +- B: `["12", 2, 0.5]` +- C: `[3, 2, 0.5]` +- D: `[1, 1, 1]` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +Array elements can hold any value. Numbers, strings, objects, other arrays, null, boolean values, undefined, and other expressions such as dates, functions, and calculations. + +The element will be equal to the returned value. `1 + 2` returns `3`, `1 * 2` returns `2`, and `1 / 2` returns `0.5`. + +

+
+ +--- + +###### 81. What is the output? + +```javascript +function sayHi(name) { + return `Hi there, ${name}`; +} + +console.log(sayHi()); +``` + +- A: `Hi there,` +- B: `Hi there, undefined` +- C: `Hi there, null` +- D: `ReferenceError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +By default, arguments have the value of `undefined`, unless a value has been passed to the function. In this case, we didn't pass a value for the `name` argument. `name` is equal to `undefined` which gets logged. + +In ES6, we can overwrite this default `undefined` value with default parameters. For example: + +`function sayHi(name = "Lydia") { ... }` + +In this case, if we didn't pass a value or if we passed `undefined`, `name` would always be equal to the string `Lydia` + +

+
+ +--- + +###### 82. What is the output? + +```javascript +var status = "😎"; + +setTimeout(() => { + const status = "😍"; + + const data = { + status: "đŸĨ‘", + getStatus() { + return this.status; + }, + }; + + console.log(data.getStatus()); + console.log(data.getStatus.call(this)); +}, 0); +``` + +- A: `"đŸĨ‘"` and `"😍"` +- B: `"đŸĨ‘"` and `"😎"` +- C: `"😍"` and `"😎"` +- D: `"😎"` and `"😎"` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +The value of the `this` keyword is dependent on where you use it. In a **method**, like the `getStatus` method, the `this` keyword refers to _the object that the method belongs to_. The method belongs to the `data` object, so `this` refers to the `data` object. When we log `this.status`, the `status` property on the `data` object gets logged, which is `"đŸĨ‘"`. + +With the `call` method, we can change the object to which the `this` keyword refers. In **functions**, the `this` keyword refers to the _the object that the function belongs to_. We declared the `setTimeout` function on the _global object_, so within the `setTimeout` function, the `this` keyword refers to the _global object_. On the global object, there is a variable called _status_ with the value of `"😎"`. When logging `this.status`, `"😎"` gets logged. + +

+
+ +--- + +###### 83. What is the output? + +```javascript +const person = { + name: "Lydia", + age: 21, +}; + +let city = person.city; +city = "Amsterdam"; + +console.log(person); +``` + +- A: `{ name: "Lydia", age: 21 }` +- B: `{ name: "Lydia", age: 21, city: "Amsterdam" }` +- C: `{ name: "Lydia", age: 21, city: undefined }` +- D: `"Amsterdam"` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +We set the variable `city` equal to the value of the property called `city` on the `person` object. There is no property on this object called `city`, so the variable `city` has the value of `undefined`. + +Note that we are _not_ referencing the `person` object itself! We simply set the variable `city` equal to the current value of the `city` property on the `person` object. + +Then, we set `city` equal to the string `"Amsterdam"`. This doesn't change the person object: there is no reference to that object. + +When logging the `person` object, the unmodified object gets returned. + +

+
+ +--- + +###### 84. What is the output? + +```javascript +function checkAge(age) { + if (age < 18) { + const message = "Sorry, you're too young."; + } else { + const message = "Yay! You're old enough!"; + } + + return message; +} + +console.log(checkAge(21)); +``` + +- A: `"Sorry, you're too young."` +- B: `"Yay! You're old enough!"` +- C: `ReferenceError` +- D: `undefined` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +Variables with the `const` and `let` keywords are _block-scoped_. A block is anything between curly brackets (`{ }`). In this case, the curly brackets of the if/else statements. You cannot reference a variable outside of the block it's declared in, a ReferenceError gets thrown. + +

+
+ +--- + +###### 85. What kind of information would get logged? + +```javascript +fetch("https://www.website.com/api/user/1") + .then((res) => res.json()) + .then((res) => console.log(res)); +``` + +- A: The result of the `fetch` method. +- B: The result of the second invocation of the `fetch` method. +- C: The result of the callback in the previous `.then()`. +- D: It would always be undefined. + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +The value of `res` in the second `.then` is equal to the returned value of the previous `.then`. You can keep chaining `.then`s like this, where the value is passed to the next handler. + +

+
+ +--- + +###### 86. Which option is a way to set `hasName` equal to `true`, provided you cannot pass `true` as an argument? + +```javascript +function getName(name) { + const hasName = // +} +``` + +- A: `!!name` +- B: `name` +- C: `new Boolean(name)` +- D: `name.length` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +With `!!name`, we determine whether the value of `name` is truthy or falsy. If the name is truthy, which we want to test for, `!name` returns `false`. `!false` (which is what `!!name` practically is) returns `true`. + +By setting `hasName` equal to `name`, you set `hasName` equal to whatever value you passed to the `getName` function, not the boolean value `true`. + +`new Boolean(true)` returns an object wrapper, not the boolean value itself. + +`name.length` returns the length of the passed argument, not whether it's `true`. + +

+
+ +--- + +###### 87. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +console.log("I want pizza"[0]); +``` + +- A: `"""` +- B: `"I"` +- C: `SyntaxError` +- D: `undefined` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +In order to get a character at a specific index of a string, you can use bracket notation. The first character in the string has index 0, and so on. In this case, we want to get the element with index 0, the character `"I'`, which gets logged. + +Note that this method is not supported in IE7 and below. In that case, use `.charAt()`. + +

+
+ +--- + +###### 88. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function sum(num1, num2 = num1) { + console.log(num1 + num2); +} + +sum(10); +``` + +- A: `NaN` +- B: `20` +- C: `ReferenceError` +- D: `undefined` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +You can set a default parameter's value equal to another parameter of the function, as long as they've been defined _before_ the default parameter. We pass the value `10` to the `sum` function. If the `sum` function only receives 1 argument, it means that the value for `num2` is not passed, and the value of `num1` is equal to the passed value `10` in this case. The default value of `num2` is the value of `num1`, which is `10`. `num1 + num2` returns `20`. + +If you're trying to set a default parameter's value equal to a parameter that is defined _after_ (to the right), the parameter's value hasn't been initialized yet, which will throw an error. + +

+
+ +--- + +###### 89. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +// module.js +export default () => "Hello world"; +export const name = "Lydia"; + +// index.js +import * as data from "./module"; + +console.log(data); +``` + +- A: `{ default: function default(), name: "Lydia" }` +- B: `{ default: function default() }` +- C: `{ default: "Hello world", name: "Lydia" }` +- D: Global object of `module.js` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +With the `import * as name` syntax, we import _all exports_ from the `module.js` file into the `index.js` file as a new object called `data` is created. In the `module.js` file, there are two exports: the default export, and a named export. The default export is a function that returns the string `"Hello World"`, and the named export is a variable called `name` which has the value of the string `"Lydia"`. + +The `data` object has a `default` property for the default export, other properties have the names of the named exports and their corresponding values. + +

+
+ +--- + +###### 90. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +class Person { + constructor(name) { + this.name = name; + } +} + +const member = new Person("John"); +console.log(typeof member); +``` + +- A: `"class"` +- B: `"function"` +- C: `"object"` +- D: `"string"` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +Classes are syntactical sugar for function constructors. The equivalent of the `Person` class as a function constructor would be: + +```javascript +function Person(name) { + this.name = name; +} +``` + +Calling a function constructor with `new` results in the creation of an instance of `Person`, `typeof` keyword returns `"object"` for an instance. `typeof member` returns `"object"`. + +

+
+ +--- + +###### 91. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +let newList = [1, 2, 3].push(4); + +console.log(newList.push(5)); +``` + +- A: `[1, 2, 3, 4, 5]` +- B: `[1, 2, 3, 5]` +- C: `[1, 2, 3, 4]` +- D: `Error` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +The `.push` method returns the _new length_ of the array, not the array itself! By setting `newList` equal to `[1, 2, 3].push(4)`, we set `newList` equal to the new length of the array: `4`. + +Then, we try to use the `.push` method on `newList`. Since `newList` is the numerical value `4`, we cannot use the `.push` method: a TypeError is thrown. + +

+
+ +--- + +###### 92. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function giveLydiaPizza() { + return "Here is pizza!"; +} + +const giveLydiaChocolate = () => + "Here's chocolate... now go hit the gym already."; + +console.log(giveLydiaPizza.prototype); +console.log(giveLydiaChocolate.prototype); +``` + +- A: `{ constructor: ...}` `{ constructor: ...}` +- B: `{}` `{ constructor: ...}` +- C: `{ constructor: ...}` `{}` +- D: `{ constructor: ...}` `undefined` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +Regular functions, such as the `giveLydiaPizza` function, have a `prototype` property, which is an object (prototype object) with a `constructor` property. Arrow functions however, such as the `giveLydiaChocolate` function, do not have this `prototype` property. `undefined` gets returned when trying to access the `prototype` property using `giveLydiaChocolate.prototype`. + +

+
+ +--- + +###### 93. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const person = { + name: "Lydia", + age: 21, +}; + +for (const [x, y] of Object.entries(person)) { + console.log(x, y); +} +``` + +- A: `name` `Lydia` and `age` `21` +- B: `["name", "Lydia"]` and `["age", 21]` +- C: `["name", "age"]` and `undefined` +- D: `Error` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +`Object.entries(person)` returns an array of nested arrays, containing the keys and objects: + +`[ [ 'name', 'Lydia' ], [ 'age', 21 ] ]` + +Using the `for-of` loop, we can iterate over each element in the array, the subarrays in this case. We can destructure the subarrays instantly in the for-of loop, using `const [x, y]`. `x` is equal to the first element in the subarray, `y` is equal to the second element in the subarray. + +The first subarray is `[ "name", "Lydia" ]`, with `x` equal to `"name"`, and `y` equal to `"Lydia"`, which get logged. +The second subarray is `[ "age", 21 ]`, with `x` equal to `"age"`, and `y` equal to `21`, which get logged. + +

+
+ +--- + +###### 94. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function getItems(fruitList, ...args, favoriteFruit) { + return [...fruitList, ...args, favoriteFruit] +} + +getItems(["banana", "apple"], "pear", "orange") +``` + +- A: `["banana", "apple", "pear", "orange"]` +- B: `[["banana", "apple"], "pear", "orange"]` +- C: `["banana", "apple", ["pear"], "orange"]` +- D: `SyntaxError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +`...args` is a rest parameter. The rest parameter's value is an array containing all remaining arguments, **and can only be the last parameter**! In this example, the rest parameter was the second parameter. This is not possible, and will throw a syntax error. + +```javascript +function getItems(fruitList, favoriteFruit, ...args) { + return [...fruitList, ...args, favoriteFruit]; +} + +getItems(["banana", "apple"], "pear", "orange"); +``` + +The above example works. This returns the array `[ 'banana', 'apple', 'orange', 'pear' ]` + +

+
+ +--- + +###### 95. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function nums(a, b) { + if (a > b) console.log("a is bigger"); + else console.log("b is bigger"); + return; + a + b; +} + +console.log(nums(4, 2)); +console.log(nums(1, 2)); +``` + +- A: `a is bigger`, `6` and `b is bigger`, `3` +- B: `a is bigger`, `undefined` and `b is bigger`, `undefined` +- C: `undefined` and `undefined` +- D: `SyntaxError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +In JavaScript, we don't _have_ to write the semicolon (`;`) explicitly, however the JavaScript engine still adds them after statements. This is called **Automatic Semicolon Insertion**. A statement can for example be variables, or keywords like `throw`, `return`, `break`, etc. + +Here, we wrote a `return` statement, and another value `a + b` on a _new line_. However, since it's a new line, the engine doesn't know that it's actually the value that we wanted to return. Instead, it automatically added a semicolon after `return`. You could see this as: + +```javascript +return; +a + b; +``` + +This means that `a + b` is never reached, since a function stops running after the `return` keyword. If no value gets returned, like here, the function returns `undefined`. Note that there is no automatic insertion after `if/else` statements! + +

+
+ +--- + +###### 96. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +class Person { + constructor() { + this.name = "Lydia"; + } +} + +Person = class AnotherPerson { + constructor() { + this.name = "Sarah"; + } +}; + +const member = new Person(); +console.log(member.name); +``` + +- A: `"Lydia"` +- B: `"Sarah"` +- C: `Error: cannot redeclare Person` +- D: `SyntaxError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +We can set classes equal to other classes/function constructors. In this case, we set `Person` equal to `AnotherPerson`. The name on this constructor is `Sarah`, so the name property on the new `Person` instance `member` is `"Sarah"`. + +

+
+ +--- + +###### 97. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const info = { + [Symbol("a")]: "b", +}; + +console.log(info); +console.log(Object.keys(info)); +``` + +- A: `{Symbol('a'): 'b'}` and `["{Symbol('a')"]` +- B: `{}` and `[]` +- C: `{ a: "b" }` and `["a"]` +- D: `{Symbol('a'): 'b'}` and `[]` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +A Symbol is not _enumerable_. The Object.keys method returns all _enumerable_ key properties on an object. The Symbol won't be visible, and an empty array is returned. When logging the entire object, all properties will be visible, even non-enumerable ones. + +This is one of the many qualities of a symbol: besides representing an entirely unique value (which prevents accidental name collision on objects, for example when working with 2 libraries that want to add properties to the same object), you can also "hide" properties on objects this way (although not entirely. You can still access symbols using the `Object.getOwnPropertySymbols()` method). + +

+
+ +--- + +###### 98. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const getList = ([x, ...y]) => [x, y] +const getUser = user => { name: user.name, age: user.age } + +const list = [1, 2, 3, 4] +const user = { name: "Lydia", age: 21 } + +console.log(getList(list)) +console.log(getUser(user)) +``` + +- A: `[1, [2, 3, 4]]` and `SyntaxError` +- B: `[1, [2, 3, 4]]` and `{ name: "Lydia", age: 21 }` +- C: `[1, 2, 3, 4]` and `{ name: "Lydia", age: 21 }` +- D: `Error` and `{ name: "Lydia", age: 21 }` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +The `getList` function receives an array as its argument. Between the parentheses of the `getList` function, we destructure this array right away. You could see this as: + +`[x, ...y] = [1, 2, 3, 4]` + +With the rest parameter `...y`, we put all "remaining" arguments in an array. The remaining arguments are `2`, `3` and `4` in this case. The value of `y` is an array, containing all the rest parameters. The value of `x` is equal to `1` in this case, so when we log `[x, y]`, `[1, [2, 3, 4]]` gets logged. + +The `getUser` function receives an object. With arrow functions, we don't _have_ to write curly brackets if we just return one value. However, if you want to instantly return an _object_ from an arrow function, you have to write it between parentheses, otherwise everything between the two braces will be interpreted as a block statement. In this case the code between the braces is not a valid JavaScript code, so a `SyntaxError` gets thrown. + +The following function would have returned an object: + +`const getUser = user => ({ name: user.name, age: user.age })` + +

+
+ +--- + +###### 99. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const name = "Lydia"; + +console.log(name()); +``` + +- A: `SyntaxError` +- B: `ReferenceError` +- C: `TypeError` +- D: `undefined` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +The variable `name` holds the value of a string, which is not a function, and thus cannot be invoked. + +TypeErrors get thrown when a value is not of the expected type. JavaScript expected `name` to be a function since we're trying to invoke it. It was a string however, so a TypeError gets thrown: name is not a function! + +SyntaxErrors get thrown when you've written something that isn't valid JavaScript, for example when you've written the word `return` as `retrun`. +ReferenceErrors get thrown when JavaScript isn't able to find a reference to a value that you're trying to access. + +

+
+ +--- + +###### 100. What's the value of output? + +```javascript +// 🎉✨ This is my 100th question! ✨🎉 + +const output = `${[] && "Im"}possible! +You should${"" && `n't`} see a therapist after so much JavaScript lol`; +``` + +- A: `possible! You should see a therapist after so much JavaScript lol` +- B: `Impossible! You should see a therapist after so much JavaScript lol` +- C: `possible! You shouldn't see a therapist after so much JavaScript lol` +- D: `Impossible! You shouldn't see a therapist after so much JavaScript lol` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +`[]` is a truthy value. With the `&&` operator, the right-hand value will be returned if the left-hand value is a truthy value. In this case, the left-hand value `[]` is a truthy value, so `"Im'` gets returned. + +`""` is a falsy value. If the left-hand value is falsy, nothing gets returned. `n't` doesn't get returned. + +

+
+ +--- + +###### 101. What's the value of output? + +```javascript +const one = false || {} || null; +const two = null || false || ""; +const three = [] || 0 || true; + +console.log(one, two, three); +``` + +- A: `false` `null` `[]` +- B: `null` `""` `true` +- C: `{}` `""` `[]` +- D: `null` `null` `true` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +With the `||` operator, we can return the first truthy operand. If all values are falsy, the last operand gets returned. + +`(false || {} || null)`: the empty object `{}` is a truthy value. This is the first (and only) truthy value, which gets returned. `one` is equal to `{}`. + +`(null || false || "")`: all operands are falsy values. This means that the last operand, `""` gets returned. `two` is equal to `""`. + +`([] || 0 || "")`: the empty array`[]` is a truthy value. This is the first truthy value, which gets returned. `three` is equal to `[]`. + +

+
+ +--- + +###### 102. What's the value of output? + +```javascript +const myPromise = () => Promise.resolve("I have resolved!"); + +function firstFunction() { + myPromise().then((res) => console.log(res)); + console.log("second"); +} + +async function secondFunction() { + console.log(await myPromise()); + console.log("second"); +} + +firstFunction(); +secondFunction(); +``` + +- A: `I have resolved!`, `second` and `I have resolved!`, `second` +- B: `second`, `I have resolved!` and `second`, `I have resolved!` +- C: `I have resolved!`, `second` and `second`, `I have resolved!` +- D: `second`, `I have resolved!` and `I have resolved!`, `second` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +With a promise, we basically say _I want to execute this function, but I'll put it aside for now while it's running since this might take a while. Only when a certain value is resolved (or rejected), and when the call stack is empty, I want to use this value._ + +We can get this value with both `.then` and the `await` keywords in an `async` function. Although we can get a promise's value with both `.then` and `await`, they work a bit differently. + +In the `firstFunction`, we (sort of) put the myPromise function aside while it was running, but continued running the other code, which is `console.log('second')` in this case. Then, the function resolved with the string `I have resolved`, which then got logged after it saw that the callstack was empty. + +With the await keyword in `secondFunction`, we literally pause the execution of an async function until the value has been resolved before moving to the next line. + +This means that it waited for the `myPromise` to resolve with the value `I have resolved`, and only once that happened, we moved to the next line: `second` got logged. + +

+
+ +--- + +###### 103. What's the value of output? + +```javascript +const set = new Set(); + +set.add(1); +set.add("Lydia"); +set.add({ name: "Lydia" }); + +for (let item of set) { + console.log(item + 2); +} +``` + +- A: `3`, `NaN`, `NaN` +- B: `3`, `7`, `NaN` +- C: `3`, `Lydia2`, `[object Object]2` +- D: `"12"`, `Lydia2`, `[object Object]2` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +The `+` operator is not only used for adding numerical values, but we can also use it to concatenate strings. Whenever the JavaScript engine sees that one or more values are not a number, it coerces the number into a string. + +The first one is `1`, which is a numerical value. `1 + 2` returns the number 3. + +However, the second one is a string `"Lydia"`. `"Lydia"` is a string and `2` is a number: `2` gets coerced into a string. `"Lydia"` and `"2"` get concatenated, which results in the string `"Lydia2"`. + +`{ name: "Lydia" }` is an object. Neither a number nor an object is a string, so it stringifies both. Whenever we stringify a regular object, it becomes `"[object Object]"`. `"[object Object]"` concatenated with `"2"` becomes `"[object Object]2"`. + +

+
+ +--- + +###### 104. What's its value? + +```javascript +Promise.resolve(5); +``` + +- A: `5` +- B: `Promise {: 5}` +- C: `Promise {: 5}` +- D: `Error` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +We can pass any type of value we want to `Promise.resolve`, either a promise or a non-promise. The method itself returns a promise with the resolved value (``). If you pass a regular function, it'll be a resolved promise with a regular value. If you pass a promise, it'll be a resolved promise with the resolved value of that passed promise. + +In this case, we just passed the numerical value `5`. It returns a resolved promise with the value `5`. + +

+
+ +--- + +###### 105. What's its value? + +```javascript +function compareMembers(person1, person2 = person) { + if (person1 !== person2) { + console.log("Not the same!"); + } else { + console.log("They are the same!"); + } +} + +const person = { name: "Lydia" }; + +compareMembers(person); +``` + +- A: `Not the same!` +- B: `They are the same!` +- C: `ReferenceError` +- D: `SyntaxError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +Objects are passed by reference. When we check objects for strict equality (`===`), we're comparing their references. + +We set the default value for `person2` equal to the `person` object, and passed the `person` object as the value for `person1`. + +This means that both values have a reference to the same spot in memory, thus they are equal. + +The code block in the `else` statement gets run, and `They are the same!` gets logged. + +

+
+ +--- + +###### 106. What's its value? + +```javascript +const colorConfig = { + red: true, + blue: false, + green: true, + black: true, + yellow: false, +}; + +const colors = ["pink", "red", "blue"]; + +console.log(colorConfig.colors[1]); +``` + +- A: `true` +- B: `false` +- C: `undefined` +- D: `TypeError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +In JavaScript, we have two ways to access properties on an object: bracket notation, or dot notation. In this example, we use dot notation (`colorConfig.colors`) instead of bracket notation (`colorConfig["colors"]`). + +With dot notation, JavaScript tries to find the property on the object with that exact name. In this example, JavaScript tries to find a property called `colors` on the `colorConfig` object. There is no property called `colors`, so this returns `undefined`. Then, we try to access the value of the first element by using `[1]`. We cannot do this on a value that's `undefined`, so it throws a `TypeError`: `Cannot read property '1' of undefined`. + +JavaScript interprets (or unboxes) statements. When we use bracket notation, it sees the first opening bracket `[` and keeps going until it finds the closing bracket `]`. Only then, it will evaluate the statement. If we would've used `colorConfig[colors[1]]`, it would have returned the value of the `red` property on the `colorConfig` object. + +

+
+ +--- + +###### 107. What's its value? + +```javascript +console.log("â¤ī¸" === "â¤ī¸"); +``` + +- A: `true` +- B: `false` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +Under the hood, emojis are unicodes. The unicodes for the heart emoji is `"U+2764 U+FE0F"`. These are always the same for the same emojis, so we're comparing two equal strings to each other, which returns true. + +

+
+ +--- + +###### 108. Which of these methods modifies the original array? + +```javascript +const emojis = ["✨", "đŸĨ‘", "😍"]; + +emojis.map((x) => x + "✨"); +emojis.filter((x) => x !== "đŸĨ‘"); +emojis.find((x) => x !== "đŸĨ‘"); +emojis.reduce((acc, cur) => acc + "✨"); +emojis.slice(1, 2, "✨"); +emojis.splice(1, 2, "✨"); +``` + +- A: `All of them` +- B: `map` `reduce` `slice` `splice` +- C: `map` `slice` `splice` +- D: `splice` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +With `splice` method, we modify the original array by deleting, replacing or adding elements. In this case, we removed 2 items from index 1 (we removed `'đŸĨ‘'` and `'😍'`) and added the ✨ emoji instead. + +`map`, `filter` and `slice` return a new array, `find` returns an element, and `reduce` returns a reduced value. + +

+
+ +--- + +###### 109. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const food = ["🍕", "đŸĢ", "đŸĨ‘", "🍔"]; +const info = { favoriteFood: food[0] }; + +info.favoriteFood = "🍝"; + +console.log(food); +``` + +- A: `['🍕', 'đŸĢ', 'đŸĨ‘', '🍔']` +- B: `['🍝', 'đŸĢ', 'đŸĨ‘', '🍔']` +- C: `['🍝', '🍕', 'đŸĢ', 'đŸĨ‘', '🍔']` +- D: `ReferenceError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +We set the value of the `favoriteFood` property on the `info` object equal to the string with the pizza emoji, `'🍕'`. A string is a primitive data type. In JavaScript, primitive data types don't interact by reference. + +In JavaScript, primitive data types (everything that's not an object) interact by _value_. In this case, we set the value of the `favoriteFood` property on the `info` object equal to the value of the first element in the `food` array, the string with the pizza emoji in this case (`'🍕'`). A string is a primitive data type, and interact by value (see my [blogpost](https://www.theavocoder.com/complete-javascript/2018/12/21/by-value-vs-by-reference) if you're interested in learning more) + +Then, we change the value of the `favoriteFood` property on the `info` object. The `food` array hasn't changed, since the value of `favoriteFood` was merely a _copy_ of the value of the first element in the array, and doesn't have a reference to the same spot in memory as the element on `food[0]`. When we log food, it's still the original array, `['🍕', 'đŸĢ', 'đŸĨ‘', '🍔']`. + +

+
+ +--- + +###### 110. What does this method do? + +```javascript +JSON.parse(); +``` + +- A: Parses JSON to a JavaScript value +- B: Parses a JavaScript object to JSON +- C: Parses any JavaScript value to JSON +- D: Parses JSON to a JavaScript object only + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +With the `JSON.parse()` method, we can parse JSON string to a JavaScript value. + +```javascript +// Stringifying a number into valid JSON, then parsing the JSON string to a JavaScript value: +const jsonNumber = JSON.stringify(4); // '4' +JSON.parse(jsonNumber); // 4 + +// Stringifying an array value into valid JSON, then parsing the JSON string to a JavaScript value: +const jsonArray = JSON.stringify([1, 2, 3]); // '[1, 2, 3]' +JSON.parse(jsonArray); // [1, 2, 3] + +// Stringifying an object into valid JSON, then parsing the JSON string to a JavaScript value: +const jsonArray = JSON.stringify({ name: "Lydia" }); // '{"name":"Lydia"}' +JSON.parse(jsonArray); // { name: 'Lydia' } +``` + +

+
+ +--- + +###### 111. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +let name = "Lydia"; + +function getName() { + console.log(name); + let name = "Sarah"; +} + +getName(); +``` + +- A: Lydia +- B: Sarah +- C: `undefined` +- D: `ReferenceError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +Each function has its own _execution context_ (or _scope_). The `getName` function first looks within its own context (scope) to see if it contains the variable `name` we're trying to access. In this case, the `getName` function contains its own `name` variable: we declare the variable `name` with the `let` keyword, and with the value of `'Sarah'`. + +Variables with the `let` keyword (and `const`) are hoisted, but unlike `var`, don't get initialized. They are not accessible before the line we declare (initialize) them. This is called the "temporal dead zone". When we try to access the variables before they are declared, JavaScript throws a `ReferenceError`. + +If we wouldn't have declared the `name` variable within the `getName` function, the javascript engine would've looked down the _scope chain_. The outer scope has a variable called `name` with the value of `Lydia`. In that case, it would've logged `Lydia`. + +```javascript +let name = "Lydia"; + +function getName() { + console.log(name); +} + +getName(); // Lydia +``` + +

+
+ +--- + +###### 112. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function* generatorOne() { + yield ["a", "b", "c"]; +} + +function* generatorTwo() { + yield* ["a", "b", "c"]; +} + +const one = generatorOne(); +const two = generatorTwo(); + +console.log(one.next().value); +console.log(two.next().value); +``` + +- A: `a` and `a` +- B: `a` and `undefined` +- C: `['a', 'b', 'c']` and `a` +- D: `a` and `['a', 'b', 'c']` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +With the `yield` keyword, we `yield` values in a generator function. With the `yield*` keyword, we can yield values from another generator function, or iterable object (for example an array). + +In `generatorOne`, we yield the entire array `['a', 'b', 'c']` using the `yield` keyword. The value of `value` property on the object returned by the `next` method on `one` (`one.next().value`) is equal to the entire array `['a', 'b', 'c']`. + +```javascript +console.log(one.next().value); // ['a', 'b', 'c'] +console.log(one.next().value); // undefined +``` + +In `generatorTwo`, we use the `yield*` keyword. This means that the first yielded value of `two`, is equal to the first yielded value in the iterator. The iterator is the array `['a', 'b', 'c']`. The first yielded value is `a`, so the first time we call `two.next().value`, `a` is returned. + +```javascript +console.log(two.next().value); // 'a' +console.log(two.next().value); // 'b' +console.log(two.next().value); // 'c' +console.log(two.next().value); // undefined +``` + +

+
+ +--- + +###### 113. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +console.log(`${((x) => x)("I love")} to program`); +``` + +- A: `I love to program` +- B: `undefined to program` +- C: `${(x => x)('I love') to program` +- D: `TypeError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +Expressions within template literals are evaluated first. This means that the string will contain the returned value of the expression, the immediately invoked function `(x => x)('I love')` in this case. We pass the value `'I love'` as an argument to the `x => x` arrow function. `x` is equal to `'I love'`, which gets returned. This results in `I love to program`. + +

+
+ +--- + +###### 114. What will happen? + +```javascript +let config = { + alert: setInterval(() => { + console.log("Alert!"); + }, 1000), +}; + +config = null; +``` + +- A: The `setInterval` callback won't be invoked +- B: The `setInterval` callback gets invoked once +- C: The `setInterval` callback will still be called every second +- D: We never invoked `config.alert()`, config is `null` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +Normally when we set objects equal to `null`, those objects get _garbage collected_ as there is no reference anymore to that object. However, since the callback function within `setInterval` is an arrow function (thus bound to the `config` object), the callback function still holds a reference to the `config` object. +As long as there is a reference, the object won't get garbage collected. +Since this is an interval, setting `config` to `null` or `delete`-ing `config.alert` won't garbage-collect the interval, so the interval will still be called. +It should be cleared with `clearInterval(config.alert)` to remove it from memory. +Since it was not cleared, the `setInterval` callback function will still get invoked every 1000ms (1s). + +

+
+ +--- + +###### 115. Which method(s) will return the value `'Hello world!'`? + +```javascript +const myMap = new Map(); +const myFunc = () => "greeting"; + +myMap.set(myFunc, "Hello world!"); + +//1 +myMap.get("greeting"); +//2 +myMap.get(myFunc); +//3 +myMap.get(() => "greeting"); +``` + +- A: 1 +- B: 2 +- C: 2 and 3 +- D: All of them + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +When adding a key/value pair using the `set` method, the key will be the value of the first argument passed to the `set` function, and the value will be the second argument passed to the `set` function. The key is the _function_ `() => 'greeting'` in this case, and the value `'Hello world'`. `myMap` is now `{ () => 'greeting' => 'Hello world!' }`. + +1 is wrong, since the key is not `'greeting'` but `() => 'greeting'`. +3 is wrong, since we're creating a new function by passing it as a parameter to the `get` method. Object interacts by _reference_. Functions are objects, which is why two functions are never strictly equal, even if they are identical: they have a reference to a different spot in memory. + +

+
+ +--- + +###### 116. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const person = { + name: "Lydia", + age: 21, +}; + +const changeAge = (x = { ...person }) => (x.age += 1); +const changeAgeAndName = (x = { ...person }) => { + x.age += 1; + x.name = "Sarah"; +}; + +changeAge(person); +changeAgeAndName(); + +console.log(person); +``` + +- A: `{name: "Sarah", age: 22}` +- B: `{name: "Sarah", age: 23}` +- C: `{name: "Lydia", age: 22}` +- D: `{name: "Lydia", age: 23}` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +Both the `changeAge` and `changeAgeAndName` functions have a default parameter, namely a _newly_ created object `{ ...person }`. This object has copies of all the key/values in the `person` object. + +First, we invoke the `changeAge` function and pass the `person` object as its argument. This function increases the value of the `age` property by 1. `person` is now `{ name: "Lydia", age: 22 }`. + +Then, we invoke the `changeAgeAndName` function, however we don't pass a parameter. Instead, the value of `x` is equal to a _new_ object: `{ ...person }`. Since it's a new object, it doesn't affect the values of the properties on the `person` object. `person` is still equal to `{ name: "Lydia", age: 22 }`. + +

+
+ +--- + +###### 117. Which of the following options will return `6`? + +```javascript +function sumValues(x, y, z) { + return x + y + z; +} +``` + +- A: `sumValues([...1, 2, 3])` +- B: `sumValues([...[1, 2, 3]])` +- C: `sumValues(...[1, 2, 3])` +- D: `sumValues([1, 2, 3])` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +With the spread operator `...`, we can _spread_ iterables to individual elements. The `sumValues` function receives three arguments: `x`, `y` and `z`. `...[1, 2, 3]` will result in `1, 2, 3`, which we pass to the `sumValues` function. + +

+
+ +--- + +###### 118. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +let num = 1; +const list = ["đŸĨŗ", "🤠", "đŸĨ°", "đŸ¤Ē"]; + +console.log(list[(num += 1)]); +``` + +- A: `🤠` +- B: `đŸĨ°` +- C: `SyntaxError` +- D: `ReferenceError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +With the `+=` operator, we're incrementing the value of `num` by `1`. `num` had the initial value `1`, so `1 + 1` is `2`. The item on the second index in the `list` array is đŸĨ°, `console.log(list[2])` prints đŸĨ°. + +

+
+ +--- + +###### 119. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const person = { + firstName: "Lydia", + lastName: "Hallie", + pet: { + name: "Mara", + breed: "Dutch Tulip Hound", + }, + getFullName() { + return `${this.firstName} ${this.lastName}`; + }, +}; + +console.log(person.pet?.name); +console.log(person.pet?.family?.name); +console.log(person.getFullName?.()); +console.log(member.getLastName?.()); +``` + +- A: `undefined` `undefined` `undefined` `undefined` +- B: `Mara` `undefined` `Lydia Hallie` `ReferenceError` +- C: `Mara` `null` `Lydia Hallie` `null` +- D: `null` `ReferenceError` `null` `ReferenceError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +With the optional chaining operator `?.`, we no longer have to explicitly check whether the deeper nested values are valid or not. If we're trying to access a property on an `undefined` or `null` value (_nullish_), the expression short-circuits and returns `undefined`. + +`person.pet?.name`: `person` has a property named `pet`: `person.pet` is not nullish. It has a property called `name`, and returns `Mara`. +`person.pet?.family?.name`: `person` has a property named `pet`: `person.pet` is not nullish. `pet` does _not_ have a property called `family`, `person.pet.family` is nullish. The expression returns `undefined`. +`person.getFullName?.()`: `person` has a property named `getFullName`: `person.getFullName()` is not nullish and can get invoked, which returns `Lydia Hallie`. +`member.getLastName?.()`: variable `member` is non-existent therefore a `ReferenceError` gets thrown! + +

+
+ +--- + +###### 120. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const groceries = ["banana", "apple", "peanuts"]; + +if (groceries.indexOf("banana")) { + console.log("We have to buy bananas!"); +} else { + console.log(`We don't have to buy bananas!`); +} +``` + +- A: We have to buy bananas! +- B: We don't have to buy bananas +- C: `undefined` +- D: `1` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +We passed the condition `groceries.indexOf("banana")` to the if-statement. `groceries.indexOf("banana")` returns `0`, which is a falsy value. Since the condition in the if-statement is falsy, the code in the `else` block runs, and `We don't have to buy bananas!` gets logged. + +

+
+ +--- + +###### 121. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const config = { + languages: [], + set language(lang) { + return this.languages.push(lang); + }, +}; + +console.log(config.language); +``` + +- A: `function language(lang) { this.languages.push(lang }` +- B: `0` +- C: `[]` +- D: `undefined` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +The `language` method is a `setter`. Setters don't hold an actual value, their purpose is to _modify_ properties. When calling a `setter` method, `undefined` gets returned. + +

+
+ +--- + +###### 122. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const name = "Lydia Hallie"; + +console.log(!typeof name === "object"); +console.log(!typeof name === "string"); +``` + +- A: `false` `true` +- B: `true` `false` +- C: `false` `false` +- D: `true` `true` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +`typeof name` returns `"string"`. The string `"string"` is a truthy value, so `!typeof name` returns the boolean value `false`. `false === "object"` and `false === "string"` both return`false`. + +(If we wanted to check whether the type was (un)equal to a certain type, we should've written `!==` instead of `!typeof`) + +

+
+ +--- + +###### 123. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const add = (x) => (y) => (z) => { + console.log(x, y, z); + return x + y + z; +}; + +add(4)(5)(6); +``` + +- A: `4` `5` `6` +- B: `6` `5` `4` +- C: `4` `function` `function` +- D: `undefined` `undefined` `6` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +The `add` function returns an arrow function, which returns an arrow function, which returns an arrow function (still with me?). The first function receives an argument `x` with the value of `4`. We invoke the second function, which receives an argument `y` with the value `5`. Then we invoke the third function, which receives an argument `z` with the value `6`. When we're trying to access the value `x`, `y` and `z` within the last arrow function, the JS engine goes up the scope chain in order to find the values for `x` and `y` accordingly. This returns `4` `5` `6`. + +

+
+ +--- + +###### 124. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +async function* range(start, end) { + for (let i = start; i <= end; i++) { + yield Promise.resolve(i); + } +} + +(async () => { + const gen = range(1, 3); + for await (const item of gen) { + console.log(item); + } +})(); +``` + +- A: `Promise {1}` `Promise {2}` `Promise {3}` +- B: `Promise {}` `Promise {}` `Promise {}` +- C: `1` `2` `3` +- D: `undefined` `undefined` `undefined` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +The generator function `range` returns an async object with promises for each item in the range we pass: `Promise{1}`, `Promise{2}`, `Promise{3}`. We set the variable `gen` equal to the async object, after which we loop over it using a `for await ... of` loop. We set the variable `item` equal to the returned Promise values: first `Promise{1}`, then `Promise{2}`, then `Promise{3}`. Since we're _awaiting_ the value of `item`, the resolved promise, the resolved _values_ of the promises get returned: `1`, `2`, then `3`. + +

+
+ +--- + +###### 125. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const myFunc = ({ x, y, z }) => { + console.log(x, y, z); +}; + +myFunc(1, 2, 3); +``` + +- A: `1` `2` `3` +- B: `{1: 1}` `{2: 2}` `{3: 3}` +- C: `{ 1: undefined }` `undefined` `undefined` +- D: `undefined` `undefined` `undefined` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +`myFunc` expects an object with properties `x`, `y` and `z` as its argument. Since we're only passing three separate numeric values (1, 2, 3) instead of one object with properties `x`, `y` and `z` ({x: 1, y: 2, z: 3}), `x`, `y` and `z` have their default value of `undefined`. + +

+
+ +--- + +###### 126. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function getFine(speed, amount) { + const formattedSpeed = new Intl.NumberFormat("en-US", { + style: "unit", + unit: "mile-per-hour", + }).format(speed); + + const formattedAmount = new Intl.NumberFormat("en-US", { + style: "currency", + currency: "USD", + }).format(amount); + + return `The driver drove ${formattedSpeed} and has to pay ${formattedAmount}`; +} + +console.log(getFine(130, 300)); +``` + +- A: The driver drove 130 and has to pay 300 +- B: The driver drove 130 mph and has to pay \$300.00 +- C: The driver drove undefined and has to pay undefined +- D: The driver drove 130.00 and has to pay 300.00 + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +With the `Intl.NumberFormat` method, we can format numeric values to any locale. We format the numeric value `130` to the `en-US` locale as a `unit` in `mile-per-hour`, which results in `130 mph`. The numeric value `300` to the `en-US` locale as a `currency` in `USD` results in `$300.00`. + +

+
+ +--- + +###### 127. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const spookyItems = ["đŸ‘ģ", "🎃", "🕸"]; +({ item: spookyItems[3] } = { item: "💀" }); + +console.log(spookyItems); +``` + +- A: `["đŸ‘ģ", "🎃", "🕸"]` +- B: `["đŸ‘ģ", "🎃", "🕸", "💀"]` +- C: `["đŸ‘ģ", "🎃", "🕸", { item: "💀" }]` +- D: `["đŸ‘ģ", "🎃", "🕸", "[object Object]"]` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +By destructuring objects, we can unpack values from the right-hand object, and assign the unpacked value to the value of the same property name on the left-hand object. In this case, we're assigning the value "💀" to `spookyItems[3]`. This means that we're modifying the `spookyItems` array, we're adding the "💀" to it. When logging `spookyItems`, `["đŸ‘ģ", "🎃", "🕸", "💀"]` gets logged. + +

+
+ +--- + +###### 128. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const name = "Lydia Hallie"; +const age = 21; + +console.log(Number.isNaN(name)); +console.log(Number.isNaN(age)); + +console.log(isNaN(name)); +console.log(isNaN(age)); +``` + +- A: `true` `false` `true` `false` +- B: `true` `false` `false` `false` +- C: `false` `false` `true` `false` +- D: `false` `true` `false` `true` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +With the `Number.isNaN` method, you can check if the value you pass is a _numeric value_ and equal to `NaN`. `name` is not a numeric value, so `Number.isNaN(name)` returns `false`. `age` is a numeric value, but is not equal to `NaN`, so `Number.isNaN(age)` returns `false`. + +With the `isNaN` method, you can check if the value you pass is not a number. `name` is not a number, so `isNaN(name)` returns true. `age` is a number, so `isNaN(age)` returns `false`. + +

+
+ +--- + +###### 129. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const randomValue = 21; + +function getInfo() { + console.log(typeof randomValue); + const randomValue = "Lydia Hallie"; +} + +getInfo(); +``` + +- A: `"number"` +- B: `"string"` +- C: `undefined` +- D: `ReferenceError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +Variables declared with the `const` keyword are not referenceable before their initialization: this is called the _temporal dead zone_. In the `getInfo` function, the variable `randomValue` is scoped in the functional scope of `getInfo`. On the line where we want to log the value of `typeof randomValue`, the variable `randomValue` isn't initialized yet: a `ReferenceError` gets thrown! The engine didn't go down the scope chain since we declared the variable `randomValue` in the `getInfo` function. + +

+
+ +--- + +###### 130. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const myPromise = Promise.resolve("Woah some cool data"); + +(async () => { + try { + console.log(await myPromise); + } catch { + throw new Error(`Oops didn't work`); + } finally { + console.log("Oh finally!"); + } +})(); +``` + +- A: `Woah some cool data` +- B: `Oh finally!` +- C: `Woah some cool data` `Oh finally!` +- D: `Oops didn't work` `Oh finally!` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +In the `try` block, we're logging the awaited value of the `myPromise` variable: `"Woah some cool data"`. Since no errors were thrown in the `try` block, the code in the `catch` block doesn't run. The code in the `finally` block _always_ runs, `"Oh finally!"` gets logged. + +

+
+ +--- + +###### 131. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const emojis = ["đŸĨ‘", ["✨", "✨", ["🍕", "🍕"]]]; + +console.log(emojis.flat(1)); +``` + +- A: `['đŸĨ‘', ['✨', '✨', ['🍕', '🍕']]]` +- B: `['đŸĨ‘', '✨', '✨', ['🍕', '🍕']]` +- C: `['đŸĨ‘', ['✨', '✨', '🍕', '🍕']]` +- D: `['đŸĨ‘', '✨', '✨', '🍕', '🍕']` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +With the `flat` method, we can create a new, flattened array. The depth of the flattened array depends on the value that we pass. In this case, we passed the value `1` (which we didn't have to, that's the default value), meaning that only the arrays on the first depth will be concatenated. `['đŸĨ‘']` and `['✨', '✨', ['🍕', '🍕']]` in this case. Concatenating these two arrays results in `['đŸĨ‘', '✨', '✨', ['🍕', '🍕']]`. + +

+
+ +--- + +###### 132. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +class Counter { + constructor() { + this.count = 0; + } + + increment() { + this.count++; + } +} + +const counterOne = new Counter(); +counterOne.increment(); +counterOne.increment(); + +const counterTwo = counterOne; +counterTwo.increment(); + +console.log(counterOne.count); +``` + +- A: `0` +- B: `1` +- C: `2` +- D: `3` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +`counterOne` is an instance of the `Counter` class. The counter class contains a `count` property on its constructor, and an `increment` method. First, we invoked the `increment` method twice by calling `counterOne.increment()`. Currently, `counterOne.count` is `2`. + + + +Then, we create a new variable `counterTwo`, and set it equal to `counterOne`. Since objects interact by reference, we're just creating a new reference to the same spot in memory that `counterOne` points to. Since it has the same spot in memory, any changes made to the object that `counterTwo` has a reference to, also apply to `counterOne`. Currently, `counterTwo.count` is `2`. + +We invoke `counterTwo.increment()`, which sets `count` to `3`. Then, we log the count on `counterOne`, which logs `3`. + + + +

+
+ +--- + +###### 133. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const myPromise = Promise.resolve(Promise.resolve("Promise")); + +function funcOne() { + setTimeout(() => console.log("Timeout 1!"), 0); + myPromise.then((res) => res).then((res) => console.log(`${res} 1!`)); + console.log("Last line 1!"); +} + +async function funcTwo() { + const res = await myPromise; + console.log(`${res} 2!`); + setTimeout(() => console.log("Timeout 2!"), 0); + console.log("Last line 2!"); +} + +funcOne(); +funcTwo(); +``` + +- A: `Promise 1! Last line 1! Promise 2! Last line 2! Timeout 1! Timeout 2!` +- B: `Last line 1! Timeout 1! Promise 1! Last line 2! Promise2! Timeout 2! ` +- C: `Last line 1! Promise 2! Last line 2! Promise 1! Timeout 1! Timeout 2!` +- D: `Timeout 1! Promise 1! Last line 1! Promise 2! Timeout 2! Last line 2!` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +First, we invoke `funcOne`. On the first line of `funcOne`, we call the _asynchronous_ `setTimeout` function, from which the callback is sent to the Web API. (see my article on the event loop here.) + +Then we call the `myPromise` promise, which is an _asynchronous_ operation. Pay attention, that now only the first then clause was added to the microtask queue. + +Both the promise and the timeout are asynchronous operations, the function keeps on running while it's busy completing the promise and handling the `setTimeout` callback. This means that `Last line 1!` gets logged first, since this is not an asynchonous operation. + +Since the callstack is not empty yet, the `setTimeout` function and promise in `funcOne` cannot get added to the callstack yet. + +In `funcTwo`, the variable `res` gets `Promise` because `Promise.resolve(Promise.resolve('Promise'))` is equivalent to `Promise.resolve('Promise')` since resolving a promise just resolves it's value. The `await` in this line stops the execution of the function until it receives the resolution of the promise and then keeps on running synchronously until completion, so `Promise 2!` and then `Last line 2!` are logged and the `setTimeout` is sent to the Web API. If the first then clause in `funcOne` had its own log statement, it would be printed before `Promise 2!`. Howewer, it executed silently and put the second then clause in microtask queue. So, the second clause will be printed after `Promise 2!`. + +Then the call stack is empty. Promises are _microtasks_ so they are resolved first when the call stack is empty so `Promise 1!` gets to be logged. + +Now, since `funcTwo` popped off the call stack, the call stack is empty. The callbacks waiting in the queue (`() => console.log("Timeout 1!")` from `funcOne`, and `() => console.log("Timeout 2!")` from `funcTwo`) get added to the call stack one by one. The first callback logs `Timeout 1!`, and gets popped off the stack. Then, the second callback logs `Timeout 2!`, and gets popped off the stack. + +

+
+ +--- + +###### 134. How can we invoke `sum` in `sum.js` from `index.js?` + +```javascript +// sum.js +export default function sum(x) { + return x + x; +} + +// index.js +import * as sum from "./sum"; +``` + +- A: `sum(4)` +- B: `sum.sum(4)` +- C: `sum.default(4)` +- D: Default aren't imported with `*`, only named exports + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +With the asterisk `*`, we import all exported values from that file, both default and named. If we had the following file: + +```javascript +// info.js +export const name = "Lydia"; +export const age = 21; +export default "I love JavaScript"; + +// index.js +import * as info from "./info"; +console.log(info); +``` + +The following would get logged: + +```javascript +{ + default: "I love JavaScript", + name: "Lydia", + age: 21 +} +``` + +For the `sum` example, it means that the imported value `sum` looks like this: + +```javascript +{ default: function sum(x) { return x + x } } +``` + +We can invoke this function, by calling `sum.default` + +

+
+ +--- + +###### 135. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const handler = { + set: () => console.log("Added a new property!"), + get: () => console.log("Accessed a property!"), +}; + +const person = new Proxy({}, handler); + +person.name = "Lydia"; +person.name; +``` + +- A: `Added a new property!` +- B: `Accessed a property!` +- C: `Added a new property!` `Accessed a property!` +- D: Nothing gets logged + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +With a Proxy object, we can add custom behavior to an object that we pass to it as the second argument. In this case, we pass the `handler` object which contains two properties: `set` and `get`. `set` gets invoked whenever we _set_ property values, and `get` gets invoked whenever we _get_ (access) property values. + +The first argument is an empty object `{}`, which is the value of `person`. To this object, the custom behavior specified in the `handler` object gets added. If we add a property to the `person` object, `set` will get invoked. If we access a property on the `person` object, `get` gets invoked. + +First, we added a new property `name` to the proxy object (`person.name = "Lydia"`). `set` gets invoked, and logs `"Added a new property!"`. + +Then, we access a property value on the proxy object, and the `get` property on the handler object is invoked. `"Accessed a property!"` gets logged. + +

+
+ +--- + +###### 136. Which of the following will modify the `person` object? + +```javascript +const person = { name: "Lydia Hallie" }; + +Object.seal(person); +``` + +- A: `person.name = "Evan Bacon"` +- B: `person.age = 21` +- C: `delete person.name` +- D: `Object.assign(person, { age: 21 })` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +With `Object.seal` we can prevent new properties from being _added_, or existing properties to be _removed_. + +However, you can still modify the value of existing properties. + +

+
+ +--- + +###### 137. Which of the following will modify the `person` object? + +```javascript +const person = { + name: "Lydia Hallie", + address: { + street: "100 Main St", + }, +}; + +Object.freeze(person); +``` + +- A: `person.name = "Evan Bacon"` +- B: `delete person.address` +- C: `person.address.street = "101 Main St"` +- D: `person.pet = { name: "Mara" }` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +The `Object.freeze` method _freezes_ an object. No properties can be added, modified, or removed. + +However, it only _shallowly_ freezes the object, meaning that only _direct_ properties on the object are frozen. If the property is another object, like `address` in this case, the properties on that object aren't frozen, and can be modified. + +

+
+ +--- + +###### 138. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const add = (x) => x + x; + +function myFunc(num = 2, value = add(num)) { + console.log(num, value); +} + +myFunc(); +myFunc(3); +``` + +- A: `2` `4` and `3` `6` +- B: `2` `NaN` and `3` `NaN` +- C: `2` `Error` and `3` `6` +- D: `2` `4` and `3` `Error` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +First, we invoked `myFunc()` without passing any arguments. Since we didn't pass arguments, `num` and `value` got their default values: num is `2`, and `value` is the returned value of the function `add`. To the `add` function, we pass `num` as an argument, which had the value of `2`. `add` returns `4`, which is the value of `value`. + +Then, we invoked `myFunc(3)` and passed the value `3` as the value for the argument `num`. We didn't pass an argument for `value`. Since we didn't pass a value for the `value` argument, it got the default value: the returned value of the `add` function. To `add`, we pass `num`, which has the value of `3`. `add` returns `6`, which is the value of `value`. + +

+
+ +--- + +###### 139. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +class Counter { + #number = 10; + + increment() { + this.#number++; + } + + getNum() { + return this.#number; + } +} + +const counter = new Counter(); +counter.increment(); + +console.log(counter.#number); +``` + +- A: `10` +- B: `11` +- C: `undefined` +- D: `SyntaxError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +In ES2020, we can add private variables in classes by using the `#`. We cannot access these variables outside of the class. When we try to log `counter.#number`, a SyntaxError gets thrown: we cannot access it outside the `Counter` class! + +

+
+ +--- + +###### 140. What's missing? + +```javascript +const teams = [ + { name: "Team 1", members: ["Paul", "Lisa"] }, + { name: "Team 2", members: ["Laura", "Tim"] }, +]; + +function* getMembers(members) { + for (let i = 0; i < members.length; i++) { + yield members[i]; + } +} + +function* getTeams(teams) { + for (let i = 0; i < teams.length; i++) { + // ✨ SOMETHING IS MISSING HERE ✨ + } +} + +const obj = getTeams(teams); +obj.next(); // { value: "Paul", done: false } +obj.next(); // { value: "Lisa", done: false } +``` + +- A: `yield getMembers(teams[i].members)` +- B: `yield* getMembers(teams[i].members)` +- C: `return getMembers(teams[i].members)` +- D: `return yield getMembers(teams[i].members)` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +In order to iterate over the `members` in each element in the `teams` array, we need to pass `teams[i].members` to the `getMembers` generator function. The generator function returns a generator object. In order to iterate over each element in this generator object, we need to use `yield*`. + +If we would've written `yield`, `return yield`, or `return`, the entire generator function would've gotten returned the first time we called the `next` method. + +

+
+ +--- + +###### 141. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const person = { + name: "Lydia Hallie", + hobbies: ["coding"], +}; + +function addHobby(hobby, hobbies = person.hobbies) { + hobbies.push(hobby); + return hobbies; +} + +addHobby("running", []); +addHobby("dancing"); +addHobby("baking", person.hobbies); + +console.log(person.hobbies); +``` + +- A: `["coding"]` +- B: `["coding", "dancing"]` +- C: `["coding", "dancing", "baking"]` +- D: `["coding", "running", "dancing", "baking"]` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +The `addHobby` function receives two arguments, `hobby` and `hobbies` with the default value of the `hobbies` array on the `person` object. + +First, we invoke the `addHobby` function, and pass `"running"` as the value for `hobby` and an empty array as the value for `hobbies`. Since we pass an empty array as the value for `hobbies`, `"running"` gets added to this empty array. + +Then, we invoke the `addHobby` function, and pass `"dancing"` as the value for `hobby`. We didn't pass a value for `hobbies`, so it gets the default value, the `hobbies` property on the `person` object. We push the hobby `dancing` to the `person.hobbies` array. + +Last, we invoke the `addHobby` function, and pass `"baking"` as the value for `hobby`, and the `person.hobbies` array as the value for `hobbies`. We push the hobby `baking` to the `person.hobbies` array. + +After pushing `dancing` and `baking`, the value of `person.hobbies` is `["coding", "dancing", "baking"]` + +

+
+ +--- + +###### 142. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +class Bird { + constructor() { + console.log("I'm a bird. đŸĻĸ"); + } +} + +class Flamingo extends Bird { + constructor() { + console.log("I'm pink. 🌸"); + super(); + } +} + +const pet = new Flamingo(); +``` + +- A: `I'm pink. 🌸` +- B: `I'm pink. 🌸` `I'm a bird. đŸĻĸ` +- C: `I'm a bird. đŸĻĸ` `I'm pink. 🌸` +- D: Nothing, we didn't call any method + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +We create the variable `pet` which is an instance of the `Flamingo` class. When we instantiate this instance, the `constructor` on `Flamingo` gets called. First, `"I'm pink. 🌸"` gets logged, after which we call `super()`. `super()` calls the constructor of the parent class, `Bird`. The constructor in `Bird` gets called, and logs `"I'm a bird. đŸĻĸ"`. + +

+
+ +--- + +###### 143. Which of the options result(s) in an error? + +```javascript +const emojis = ["🎄", "🎅đŸŧ", "🎁", "⭐"]; + +/* 1 */ emojis.push("đŸĻŒ"); +/* 2 */ emojis.splice(0, 2); +/* 3 */ emojis = [...emojis, "đŸĨ‚"]; +/* 4 */ emojis.length = 0; +``` + +- A: 1 +- B: 1 and 2 +- C: 3 and 4 +- D: 3 + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +The `const` keyword simply means we cannot _redeclare_ the value of that variable, it's _read-only_. However, the value itself isn't immutable. The properties on the `emojis` array can be modified, for example by pushing new values, splicing them, or setting the length of the array to 0. + +

+
+ +--- + +###### 144. What do we need to add to the `person` object to get `["Lydia Hallie", 21]` as the output of `[...person]`? + +```javascript +const person = { + name: "Lydia Hallie", + age: 21 +} + +[...person] // ["Lydia Hallie", 21] +``` + +- A: Nothing, object are iterable by default +- B: `*[Symbol.iterator]() { for (let x in this) yield* this[x] }` +- C: `*[Symbol.iterator]() { yield* Object.values(this) }` +- D: `*[Symbol.iterator]() { for (let x in this) yield this }` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +Objects aren't iterable by default. An iterable is an iterable if the iterator protocol is present. We can add this manually by adding the iterator symbol `[Symbol.iterator]`, which has to return a generator object, for example by making it a generator function `*[Symbol.iterator]() {}`. This generator function has to yield the `Object.values` of the `person` object if we want it to return the array `["Lydia Hallie", 21]`: `yield* Object.values(this)`. + +

+
+ +--- + +###### 145. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +let count = 0; +const nums = [0, 1, 2, 3]; + +nums.forEach((num) => { + if (num) count += 1; +}); + +console.log(count); +``` + +- A: 1 +- B: 2 +- C: 3 +- D: 4 + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +The `if` condition within the `forEach` loop checks whether the value of `num` is truthy or falsy. Since the first number in the `nums` array is `0`, a falsy value, the `if` statement's code block won't be executed. `count` only gets incremented for the other 3 numbers in the `nums` array, `1`, `2` and `3`. Since `count` gets incremented by `1` 3 times, the value of `count` is `3`. + +

+
+ +--- + +###### 146. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +function getFruit(fruits) { + console.log(fruits?.[1]?.[1]); +} + +getFruit([["🍊", "🍌"], ["🍍"]]); +getFruit(); +getFruit([["🍍"], ["🍊", "🍌"]]); +``` + +- A: `null`, `undefined`, 🍌 +- B: `[]`, `null`, 🍌 +- C: `[]`, `[]`, 🍌 +- D: `undefined`, `undefined`, 🍌 + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +The `?` allows us to optionally access deeper nested properties within objects. We're trying to log the item on index `1` within the subarray that's on index `1` of the `fruits` array. If the subarray on index `1` in the `fruits` array doesn't exist, it'll simply return `undefined`. If the subarray on index `1` in the `fruits` array exists, but this subarray doesn't have an item on its `1` index, it'll also return `undefined`. + +First, we're trying to log the second item in the `['🍍']` subarray of `[['🍊', '🍌'], ['🍍']]`. This subarray only contains one item, which means there is no item on index `1`, and returns `undefined`. + +Then, we're invoking the `getFruits` function without passing a value as an argument, which means that `fruits` has a value of `undefined` by default. Since we're conditionally chaining the item on index `1` of`fruits`, it returns `undefined` since this item on index `1` does not exist. + +Lastly, we're trying to log the second item in the `['🍊', '🍌']` subarray of `['🍍'], ['🍊', '🍌']`. The item on index `1` within this subarray is `🍌`, which gets logged. + +

+
+ +--- + +###### 147. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +class Calc { + constructor() { + this.count = 0; + } + + increase() { + this.count++; + } +} + +const calc = new Calc(); +new Calc().increase(); + +console.log(calc.count); +``` + +- A: `0` +- B: `1` +- C: `undefined` +- D: `ReferenceError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +We set the variable `calc` equal to a new instance of the `Calc` class. Then, we instantiate a new instance of `Calc`, and invoke the `increase` method on this instance. Since the count property is within the constructor of the `Calc` class, the count property is not shared on the prototype of `Calc`. This means that the value of count has not been updated for the instance calc points to, count is still `0`. + +

+
+ +--- + +###### 148. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const user = { + email: "e@mail.com", + password: "12345", +}; + +const updateUser = ({ email, password }) => { + if (email) { + Object.assign(user, { email }); + } + + if (password) { + user.password = password; + } + + return user; +}; + +const updatedUser = updateUser({ email: "new@email.com" }); + +console.log(updatedUser === user); +``` + +- A: `false` +- B: `true` +- C: `TypeError` +- D: `ReferenceError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +The `updateUser` function updates the values of the `email` and `password` properties on user, if their values are passed to the function, after which the function returns the `user` object. The returned value of the `updateUser` function is the `user` object, which means that the value of updatedUser is a reference to the same `user` object that `user` points to. `updatedUser === user` equals `true`. + +

+
+ +--- + +###### 149. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const fruit = ["🍌", "🍊", "🍎"]; + +fruit.slice(0, 1); +fruit.splice(0, 1); +fruit.unshift("🍇"); + +console.log(fruit); +``` + +- A: `['🍌', '🍊', '🍎']` +- B: `['🍊', '🍎']` +- C: `['🍇', '🍊', '🍎']` +- D: `['🍇', '🍌', '🍊', '🍎']` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +First, we invoke the `slice` method on the fruit array. The slice method does not modify the original array, but returns the value that it sliced off the array: the banana emoji. +Then, we invoke the `splice` method on the fruit array. The splice method does modify the original array, which means that the fruit array now consists of `['🍊', '🍎']`. +At last, we invoke the `unshift` method on the `fruit` array, which modifies the original array by adding the provided value, ‘🍇’ in this case, as the first element in the array. The fruit array now consists of `['🍇', '🍊', '🍎']`. + +

+
+ +--- + +###### 150. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const animals = {}; +let dog = { emoji: "đŸļ" }; +let cat = { emoji: "🐈" }; + +animals[dog] = { ...dog, name: "Mara" }; +animals[cat] = { ...cat, name: "Sara" }; + +console.log(animals[dog]); +``` + +- A: `{ emoji: "đŸļ", name: "Mara" }` +- B: `{ emoji: "🐈", name: "Sara" }` +- C: `undefined` +- D: `ReferenceError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +Object keys are converted to strings. + +Since the value of `dog` is an object, `animals[dog]` actually means that we’re creating a new property called `"[object Object]"` equal to the new object. `animals["[object Object]"]` is now equal to `{ emoji: "đŸļ", name: "Mara"}`. + +`cat` is also an object, which means that `animals[cat]` actually means that we’re overwriting the value of `animals["[object Object]"]` with the new cat properties. + +Logging `animals[dog]`, or actually `animals["[object Object]"]` since converting the `dog` object to a string results `"[object Object]"`, returns the `{ emoji: "🐈", name: "Sara" }`. + +

+
+ +--- + +###### 151. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const user = { + email: "my@email.com", + updateEmail: (email) => { + this.email = email; + }, +}; + +user.updateEmail("new@email.com"); +console.log(user.email); +``` + +- A: `my@email.com` +- B: `new@email.com` +- C: `undefined` +- D: `ReferenceError` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: A + +The `updateEmail` function is an arrow function, and is not bound to the `user` object. This means that the `this` keyword is not referring to the `user` object, but refers to the global scope in this case. The value of `email` within the `user` object does not get updated. When logging the value of `user.email`, the original value of `my@email.com` gets returned. + +

+
+ +--- + +###### 152. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const promise1 = Promise.resolve("First"); +const promise2 = Promise.resolve("Second"); +const promise3 = Promise.reject("Third"); +const promise4 = Promise.resolve("Fourth"); + +const runPromises = async () => { + const res1 = await Promise.all([promise1, promise2]); + const res2 = await Promise.all([promise3, promise4]); + return [res1, res2]; +}; + +runPromises() + .then((res) => console.log(res)) + .catch((err) => console.log(err)); +``` + +- A: `[['First', 'Second'], ['Fourth']]` +- B: `[['First', 'Second'], ['Third', 'Fourth']]` +- C: `[['First', 'Second']]` +- D: `'Third'` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: D + +The `Promise.all` method runs the passed promises in parallel. If one promise fails, the `Promise.all` method _rejects_ with the value of the rejected promise. In this case, `promise3` is rejected with the value `"Third"`. We’re catching the rejected value in the chained `catch` method on the `runPromises` invocation to catch any errors within the `runPromises` function. Only `"Third"` gets logged, since `promise3` is rejected with this value. + +

+
+ +--- + +###### 153. What should the value of `method` be to log `{ name: "Lydia", age: 22 }`? + +```javascript +const keys = ["name", "age"]; +const values = ["Lydia", 22]; + +const method = + /* ?? */ + Object[method]( + keys.map((_, i) => { + return [keys[i], values[i]]; + }) + ); // { name: "Lydia", age: 22 } +``` + +- A: `entries` +- B: `values` +- C: `fromEntries` +- D: `forEach` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +The `fromEntries` method turns a 2d array into an object. The first element in each subarray will be the key, and the second element in each subarray will be the value. In this case, we’re mapping over the `keys` array, which returns an array that the first element is the item on the key array on the current index, and the second element is the item of the values array on the current index. + +This creates an array of subarrays containing the correct keys and values, which results in `{ name: "Lydia", age: 22 }` + +

+
+ +--- + +###### 154. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +const createMember = ({ email, address = {} }) => { + const validEmail = /.+\@.+\..+/.test(email); + if (!validEmail) throw new Error("Valid email pls"); + + return { + email, + address: address ? address : null, + }; +}; + +const member = createMember({ email: "my@email.com" }); +console.log(member); +``` + +- A: `{ email: "my@email.com", address: null }` +- B: `{ email: "my@email.com" }` +- C: `{ email: "my@email.com", address: {} }` +- D: `{ email: "my@email.com", address: undefined }` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: C + +The default value of `address` is an empty object `{}`. When we set the variable `member` equal to the object returned by the `createMember` function, we didn't pass a value for the address, which means that the value of the address is the default empty object `{}`. An empty object is a truthy value, which means that the condition of the `address ? address : null` conditional returns `true`. The value of the address is the empty object `{}`. + +

+
+ +--- + +###### 155. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? + +```javascript +let randomValue = { name: "Lydia" }; +randomValue = 23; + +if (!typeof randomValue === "string") { + console.log("It's not a string!"); +} else { + console.log("Yay it's a string!"); +} +``` + +- A: `It's not a string!` +- B: `Yay it's a string!` +- C: `TypeError` +- D: `undefined` + +
āωāĻ¤ā§āϤāϰ āĻĻ⧇āϖ⧁āύ +

+ +#### āωāĻ¤ā§āϤāϰ: B + +The condition within the `if` statement checks whether the value of `!typeof randomValue` is equal to `"string"`. The `!` operator converts the value to a boolean value. If the value is truthy, the returned value will be `false`, if the value is falsy, the returned value will be `true`. In this case, the returned value of `typeof randomValue` is the truthy value `"number"`, meaning that the value of `!typeof randomValue` is the boolean value `false`. + +`!typeof randomValue === "string"` always returns false, since we're actually checking `false === "string"`. Since the condition returned `false`, the code block of the `else` statement gets run, and `Yay it's a string!` gets logged. + +

+
From 6fd5ba15ed93a887adbcb0fae91dae72c1833a5c Mon Sep 17 00:00:00 2001 From: iamsaief Date: Mon, 20 May 2024 04:48:36 +0600 Subject: [PATCH 02/12] added translation till 44 --- README.md | 2 +- bn-BD/README_bn-BD.md | 532 +++++++++++++++++++++--------------------- 2 files changed, 270 insertions(+), 264 deletions(-) diff --git a/README.md b/README.md index 33993983..91f9b967 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ From basic to advanced: test how well you know JavaScript, refresh your knowledg | Feel free to use them in a project! 😃 I would _really_ appreciate a reference to this repo, I create the questions and explanations (yes I'm sad lol) and the community helps me so much to maintain and improve it! đŸ’ĒđŸŧ Thank you and have fun! | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -
See 20 Available Translations 🇸đŸ‡ĻđŸ‡ĒđŸ‡Ŧ🇧đŸ‡Ļ🇩đŸ‡ĒđŸ‡Ē🇸đŸ‡ĢđŸ‡ˇđŸ‡ŽđŸ‡ŠđŸ‡¯đŸ‡ĩđŸ‡°đŸ‡ˇđŸ‡ŗđŸ‡ąđŸ‡§đŸ‡ˇđŸ‡ˇđŸ‡ē🇹🇭🇹🇷đŸ‡ēđŸ‡ĻđŸ‡ģđŸ‡ŗđŸ‡¨đŸ‡ŗđŸ‡šđŸ‡ŧđŸ‡Ŋ🇰 +
See 21 Available Translations 🇸đŸ‡ĻđŸ‡ĒđŸ‡Ŧ🇧đŸ‡Ļ🇩đŸ‡ĒđŸ‡Ē🇸đŸ‡ĢđŸ‡ˇđŸ‡ŽđŸ‡ŠđŸ‡¯đŸ‡ĩđŸ‡°đŸ‡ˇđŸ‡ŗđŸ‡ąđŸ‡§đŸ‡ˇđŸ‡ˇđŸ‡ē🇹🇭🇹🇷đŸ‡ēđŸ‡ĻđŸ‡ģđŸ‡ŗđŸ‡¨đŸ‡ŗđŸ‡šđŸ‡ŧđŸ‡Ŋ🇰🇧🇩

- [🇸đŸ‡Ļ Ø§Ų„ØšØąØ¨ŲŠØŠ](./ar-AR/README_AR.md) diff --git a/bn-BD/README_bn-BD.md b/bn-BD/README_bn-BD.md index 7f8d0060..d9a00cf2 100644 --- a/bn-BD/README_bn-BD.md +++ b/bn-BD/README_bn-BD.md @@ -52,7 +52,7 @@ function sayHi() { console.log(name); console.log(age); - var name = "Lydia"; + var name = 'Lydia'; let age = 21; } @@ -135,7 +135,7 @@ console.log(shape.perimeter()); > āĻ–ā§‡ā§ŸāĻžāϞ āĻ•āϰ⧁āύ āĻāĻ–āĻžāύ⧇ `diameter` āĻāĻ•āϟāĻŋ āϏāĻžāϧāĻžāϰāύ āĻĢāĻžāĻ‚āĻļāύ āĻ…āĻ¨ā§āϝāĻĻāĻŋāϕ⧇ `perimeter` āĻšāĻšā§āϛ⧇ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧋ āĻĢāĻžāĻ‚āĻļāύāĨ¤ -āĻ…ā§āϝāĻžāϰ⧋ āĻĢāĻžāĻ‚āĻļāύ⧇āϰ `this` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄ āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ¸ā§āϕ⧋āĻĒāϕ⧇ āϰ⧇āĻĢāĻžāϰ (āĻĒā§Ÿā§‡āĻ¨ā§āϟ) āĻ•āϰ⧇, āĻ•āĻŋāĻ¨ā§āϤ⧁ āϏāĻžāϧāĻžāϰāύ āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āύāĻŋāĻœā§‡āϰ āĻ¸ā§āϕ⧋āĻĒ⧇āχ āĻĒā§Ÿā§‡āĻ¨ā§āϟ āĻ•āϰ⧇āĨ¤ āĻŽāĻžāύ⧇ āĻšāϞ, āϝāĻ–āύ āφāĻŽāϰāĻž `perimeter` āϕ⧇ āĻ•āϞ āĻ•āϰāĻ›āĻŋ āĻāϟāĻž shape āĻ…āĻŦā§āĻœā§‡āĻ•ā§āϟ āϕ⧇ āϰ⧇āĻĢāĻžāϰ āĻ•āϰāϛ⧇ āύāĻž āĻŦāϰāĻ‚ āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ¸ā§āϕ⧋āĻĒāϕ⧇ āĻ•āϰāϛ⧇ (āωāĻĻāĻžāĻšāϰāύāĻ¸ā§āĻŦāϰ⧂āĻĒ - window)āĨ¤ +āĻ…ā§āϝāĻžāϰ⧋ āĻĢāĻžāĻ‚āĻļāύ⧇āϰ `this` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄ āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ¸ā§āϕ⧋āĻĒāϕ⧇ āϰ⧇āĻĢāĻžāϰ (āĻĒā§Ÿā§‡āĻ¨ā§āϟ) āĻ•āϰ⧇, āĻ•āĻŋāĻ¨ā§āϤ⧁ āϏāĻžāϧāĻžāϰāύ āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āύāĻŋāĻœā§‡āϰ āĻ¸ā§āϕ⧋āĻĒ⧇āχ āĻĒā§Ÿā§‡āĻ¨ā§āϟ āĻ•āϰ⧇āĨ¤ āĻŽāĻžāύ⧇ āĻšāϞ, āϝāĻ–āύ āφāĻŽāϰāĻž `perimeter` āϕ⧇ āĻ•āϞ āĻ•āϰāĻ›āĻŋ āĻāϟāĻž shape āĻ…āĻŦā§āĻœā§‡āĻ•ā§āϟ āϕ⧇ āϰ⧇āĻĢāĻžāϰ āĻ•āϰāϛ⧇ āύāĻž āĻŦāϰāĻ‚ āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ¸ā§āϕ⧋āĻĒāϕ⧇ āĻ•āϰāϛ⧇ (āωāĻĻāĻžāĻšāϰāύāĻ¸ā§āĻŦāϰ⧂āĻĒ - window)āĨ¤ āϝ⧇āĻšā§‡āϤ⧁ āĻ…ā§āϝāĻžāϰ⧋ āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āĻ¸ā§āϕ⧋āĻĒ⧇ `radius` āĻāϰ āϕ⧋āύ āĻ­ā§āϝāĻžāϞ⧁ āύ⧇āχ `this.radius` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇ `undefined` āĻāϕ⧇ ⧍ āĻĻāĻŋā§Ÿā§‡ āϗ⧁āύ āĻ•āϰāĻžāϰ āĻĢāϞ⧇ (`2 * Math.PI`) āĻĢāϞāĻžāĻĢāϞ āφāϏāϛ⧇ `NaN`. @@ -148,7 +148,7 @@ console.log(shape.perimeter()); ```javascript +true; -!"Lydia"; +!'Lydia'; ``` - A: `1` and `false` @@ -164,7 +164,6 @@ console.log(shape.perimeter()); `'Lydia'` āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āϟāĻŋ āĻāĻ•āϟāĻŋ āϏāĻ¤ā§āϝ āĻ­ā§āϝāĻžāϞ⧁āĨ¤ āφāĻŽāϰāĻž āĻāĻ–āĻžāύ⧇ āφāϏāϞ⧇ `!` āĻĻāĻŋā§Ÿā§‡ āϝ⧇āϟāĻž āϜāĻŋāĻœā§āĻžā§‡āϏ āĻ•āϰāĻ›āĻŋ "āĻāχ āϏāĻ¤ā§āϝ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻ•āĻŋ āĻŽāĻŋāĻĨā§āϝāĻž ?"āĨ¤ āĻāϟāĻŋ āĻĢāϞāĻžāĻĢāϞ āĻĻāĻŋāĻšā§āϛ⧇ `false`āĨ¤ -

@@ -174,11 +173,11 @@ console.log(shape.perimeter()); ```javascript const bird = { - size: "small", + size: 'small', }; const mouse = { - name: "Mickey", + name: 'Mickey', small: true, }; ``` @@ -207,11 +206,11 @@ const mouse = { ###### 6. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -let c = { greeting: "Hey!" }; +let c = { greeting: 'Hey!' }; let d; d = c; -c.greeting = "Hello"; +c.greeting = 'Hello'; console.log(d.greeting); ``` @@ -263,7 +262,7 @@ console.log(b === c); `new Number()` āĻšāϞ āĻāĻ•āϟāĻŋ āĻŦāĻŋāĻ˛ā§āϟ-āχāύ āĻĢāĻžāĻ‚āĻļāύ āĻ•āĻ¨ā§āϏāĻŸā§āϰāĻžāĻ•ā§āϟāϰāĨ¤ āϝāĻĻāĻŋāĻ“ āĻāϟāĻž āύāĻžāĻŽā§āĻŦāĻžāϰ āĻāϰ āĻŽāϤ āĻĻ⧇āĻ–āϤ⧇ āĻ•āĻŋāĻ¨ā§āϤ⧁ āĻāϟāĻŋ āφāϏāϞ⧇ āύāĻžāĻŽā§āĻŦāĻžāϰ āύ⧟āσ āĻāϟāĻžāϤ⧇ āφāϰ āĻ…āύ⧇āĻ•āϗ⧁āϞ⧋ āĻĢāĻŋāϚāĻžāϰ āφāϛ⧇ āĻāĻŦāĻ‚ āĻāϟāĻŋ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāĨ¤ -āϝāĻ–āύ āφāĻŽāϰāĻž `==` āĻ…āĻĒāĻžāϰ⧇āϟāϰ (āϏāĻŽāϤ⧁āĻ˛ā§āϝ āĻ…āĻĒāĻžāϰ⧇āϟāϰ) āĻŦā§āϝāĻžāĻŦāĻšāĻžāϰ āĻ•āϰāĻŋ, āĻāϟāĻž āϕ⧇āĻŦāϞ āĻ­ā§āϝāĻžāϞ⧁ āϏāĻŽāĻžāύ āĻ•āĻŋāύāĻž āϤ⧁āϞāύāĻž āĻ•āϰ⧇āĨ¤ `a` āĻ“ `b` āĻĻ⧁āϟāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁āχ `3` āϤāĻžāχ āĻĢāϞāĻžāĻĢāϞ āĻšā§Ÿ `true`āĨ¤ +āϝāĻ–āύ āφāĻŽāϰāĻž `==` āĻ…āĻĒāĻžāϰ⧇āϟāϰ (āϏāĻŽāϤ⧁āĻ˛ā§āϝ āĻ…āĻĒāĻžāϰ⧇āϟāϰ) āĻŦā§āϝāĻžāĻŦāĻšāĻžāϰ āĻ•āϰāĻŋ, āĻāϟāĻž āϕ⧇āĻŦāϞ āĻ­ā§āϝāĻžāϞ⧁ āϏāĻŽāĻžāύ āĻ•āĻŋāύāĻž āϤ⧁āϞāύāĻž āĻ•āϰ⧇āĨ¤ `a` āĻ“ `b` āĻĻ⧁āϟāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁āχ `3` āϤāĻžāχ āĻĢāϞāĻžāĻĢāϞ āĻšā§Ÿ `true`āĨ¤ āĻ…āĻ¨ā§āϝāĻĻāĻŋāϕ⧇, āϝāĻ–āύ āφāĻŽāϰāĻž `===` āĻ…āĻĒāĻžāϰ⧇āϟāϰ (āĻ•āĻ ā§‹āϰ-āϏāĻŽāϤ⧁āĻ˛ā§āϝ āĻ…āĻĒāĻžāϰ⧇āϟāϰ) āĻŦā§āϝāĻžāĻŦāĻšāĻžāϰ āĻ•āϰāĻŋ, āĻāϟāĻž āĻ­ā§āϝāĻžāϞ⧁ āĻāĻŦāĻ‚ āϟāĻžāχāĻĒ āĻĻ⧁āϟāĻžāχ āϏāĻŽāĻžāύ āĻ•āĻŋāύāĻž āϤ⧁āϞāύāĻž āĻ•āϰ⧇āĨ¤ āĻāĻ•ā§āώāĻ¤ā§āϰ⧇ `new Number()` āϝ⧇āĻšā§‡āϤ⧁ āύāĻžāĻŽā§āĻŦāϰ āύ⧟ āĻ…āĻŦ⧇āĻœā§‡āĻ•ā§āϟāĨ¤ āĻĻ⧁āϟāχ āĻĢāϞāĻžāĻĢāϞ āĻĻā§‡ā§Ÿ `false`āĨ¤ @@ -281,13 +280,13 @@ class Chameleon { return this.newColor; } - constructor({ newColor = "green" } = {}) { + constructor({ newColor = 'green' } = {}) { this.newColor = newColor; } } -const freddie = new Chameleon({ newColor: "purple" }); -console.log(freddie.colorChange("orange")); +const freddie = new Chameleon({ newColor: 'purple' }); +console.log(freddie.colorChange('orange')); ``` - A: `orange` @@ -324,14 +323,14 @@ console.log(greetign); #### āωāĻ¤ā§āϤāϰ: A -āĻāϟāĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āϞāĻ— āĻ•āϰāϛ⧇, āĻ•āĻžāϰāύ āφāĻŽāϰāĻž āĻ–āĻžāϞāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϟāĻŋāϕ⧇ āϤ⧈āϰāĻŋ āĻ•āϰ⧇āĻ›āĻŋ āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻŽāĻ§ā§āϝ⧇! āϝāĻ–āύ `greeting` āϕ⧇ `greetign` āϭ⧁āϞ āĻŦāĻžāύāĻžāύ āĻ āϞāĻŋāϖ⧇āĻ›āĻŋ, āĻœā§‡āĻāϏ āχāĻ¨ā§āϟāĻžāϰāĻĒā§āϰ⧇āϟāĻžāϰ āĻĻ⧇āĻ–āϛ⧇ āĻāĻŽāύāσ +āĻāϟāĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āϞāĻ— āĻ•āϰāϛ⧇, āĻ•āĻžāϰāύ āφāĻŽāϰāĻž āĻ–āĻžāϞāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϟāĻŋāϕ⧇ āϤ⧈āϰāĻŋ āĻ•āϰ⧇āĻ›āĻŋ āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻŽāĻ§ā§āϝ⧇! āϝāĻ–āύ `greeting` āϕ⧇ `greetign` āϭ⧁āϞ āĻŦāĻžāύāĻžāύ āĻ āϞāĻŋāϖ⧇āĻ›āĻŋ, āĻœā§‡āĻāϏ āχāĻ¨ā§āϟāĻžāϰāĻĒā§āϰ⧇āϟāĻžāϰ āĻĻ⧇āĻ–āϛ⧇ āĻāĻŽāύāσ -1. āύ⧋āĻĄ āĻœā§‡āĻ“āĻāϏ āĻ - `global.greetign = {}`āĨ¤ -2. āĻŦā§āϰāĻžāωāϜāĻžāϰ āĻ - `window.greetign = {}`, `frames.greetign = {}` āĻāĻŦāĻ‚ `self.greetign`āĨ¤ -3. āĻ“ā§Ÿā§‡āĻŦ āĻ“ā§ŸāĻžāĻ°ā§āĻ•āĻžāĻ°ā§āϏ āĻ - `self.greetign`āĨ¤ +1. āύ⧋āĻĄ āĻœā§‡āĻ“āĻāϏ āĻ - `global.greetign = {}`āĨ¤ +2. āĻŦā§āϰāĻžāωāϜāĻžāϰ āĻ - `window.greetign = {}`, `frames.greetign = {}` āĻāĻŦāĻ‚ `self.greetign`āĨ¤ +3. āĻ“ā§Ÿā§‡āĻŦ āĻ“ā§ŸāĻžāĻ°ā§āĻ•āĻžāĻ°ā§āϏ āĻ - `self.greetign`āĨ¤ 4. āĻ…āĻ¨ā§āϝ āϏāĻ•āϞ āĻāύāĻ­āĻžā§ŸāĻ°ā§āĻ¨ā§āĻŽā§‡āĻ¨ā§āĻŸā§‡ - `globalThis.greetign`āĨ¤ -āĻāϟāĻžāϕ⧇ āĻā§œāĻžāύ⧋āϰ āϜāĻ¨ā§āϝ āφāĻŽāϰāĻž `"use strict"` āĻŦā§āϝāĻžāĻŦāĻšāĻžāϰ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ āĨ¤ āĻāϟāĻž āύāĻŋāĻļā§āϚāĻŋāϤ āĻ•āϰāĻŦ⧇ āϝ⧇ āφāĻĒāύāĻŋ āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞāϕ⧇ āϕ⧋āύ āĻ•āĻŋāϛ⧁ āĻĻāĻŋā§Ÿā§‡ āĻ…ā§āϝāĻžāϏāĻžāχāύ āĻ•āϰāĻžāϰ āφāϗ⧇ āϤāĻžāϕ⧇ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰ⧇āϛ⧇āύ āĻ•āĻŋāύāĻž āĨ¤ +āĻāϟāĻžāϕ⧇ āĻā§œāĻžāύ⧋āϰ āϜāĻ¨ā§āϝ āφāĻŽāϰāĻž `"use strict"` āĻŦā§āϝāĻžāĻŦāĻšāĻžāϰ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ āĨ¤ āĻāϟāĻž āύāĻŋāĻļā§āϚāĻŋāϤ āĻ•āϰāĻŦ⧇ āϝ⧇ āφāĻĒāύāĻŋ āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞāϕ⧇ āϕ⧋āύ āĻ•āĻŋāϛ⧁ āĻĻāĻŋā§Ÿā§‡ āĻ…ā§āϝāĻžāϏāĻžāχāύ āĻ•āϰāĻžāϰ āφāϗ⧇ āϤāĻžāϕ⧇ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰ⧇āϛ⧇āύ āĻ•āĻŋāύāĻž āĨ¤

@@ -342,10 +341,10 @@ console.log(greetign); ```javascript function bark() { - console.log("Woof!"); + console.log('Woof!'); } -bark.animal = "dog"; +bark.animal = 'dog'; ``` - A: Nothing, this is totally fine! @@ -362,7 +361,6 @@ bark.animal = "dog"; āĻĢāĻžāĻ‚āĻļāύāϗ⧁āϞ⧋ āĻšā§Ÿ āĻŦāĻŋāĻļ⧇āώ āϧāϰāύ⧇āϰ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāĨ¤ āϝ⧇ āϕ⧋āĻĄāϟāĻž āφāĻĒāύāĻŋ āϞāĻŋāϖ⧇āϛ⧇āύ āĻāϟāĻž āφāϏāϞ āĻĢāĻžāĻ‚āĻļāύ āύ⧟āĨ¤ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻšāĻšā§āϛ⧇ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āϝāĻžāϰ āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋāϏ āĻ°ā§Ÿā§‡āϛ⧇āĨ¤ āĻāχ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϗ⧁āϞ⧋āϕ⧇ āĻ•āϞ āĻ•āϰāĻž āϝāĻžā§ŸāĨ¤ -

@@ -376,7 +374,7 @@ function Person(firstName, lastName) { this.lastName = lastName; } -const member = new Person("Lydia", "Hallie"); +const member = new Person('Lydia', 'Hallie'); Person.getFullName = function () { return `${this.firstName} ${this.lastName}`; }; @@ -417,8 +415,8 @@ function Person(firstName, lastName) { this.lastName = lastName; } -const lydia = new Person("Lydia", "Hallie"); -const sarah = Person("Sarah", "Smith"); +const lydia = new Person('Lydia', 'Hallie'); +const sarah = Person('Sarah', 'Smith'); console.log(lydia); console.log(sarah); @@ -488,7 +486,7 @@ function sum(a, b) { return a + b; } -sum(1, "2"); +sum(1, '2'); ``` - A: `NaN` @@ -503,7 +501,7 @@ sum(1, "2"); āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āĻāĻ•āϟāĻŋ **āĻĄāĻžā§ŸāύāĻžāĻŽāĻŋāĻ• āϟāĻžāχāĻĒ āĻ­āĻžāώāĻžāσ** āφāĻŽāϰāĻž āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞ⧇āϰ āϟāĻžāχāĻĒ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻ•āϰāĻŋ āύāĻžāĨ¤ āφāĻĒāύāĻŋ āϜāĻžāύāϤ⧇ āĻĒāĻžāϰ⧇āύ āύāĻž āĻ­ā§āϝāĻžāϞ⧁ āĻ¸ā§āĻŦ⧟āĻ‚āĻ•ā§āϰāĻŋ⧟āĻ­āĻžāĻŦ⧇āχ āĻāĻ• āϟāĻžāχāĻĒ āĻĨ⧇āϕ⧇ āĻ…āĻ¨ā§āϝ āϟāĻžāχāĻĒ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻšā§Ÿā§‡ āϝāĻžā§Ÿ, āϝ⧇āϟāĻžāϕ⧇ āĻŦāϞāĻž āĻšā§Ÿ **āĻ•ā§‹ā§ŸāĻžāĻ°ā§āĻļāύ (coercion)**āĨ¤ āĻāϟāĻž āĻšāϞ āĻāĻ• āϟāĻžāχāĻĒ āĻĨ⧇āϕ⧇ āĻ…āĻ¨ā§āϝ āϟāĻžāχāĻĒ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻšāĻ“ā§ŸāĻžāĨ¤ -āĻāχ āωāĻĻāĻžāĻšāϰāύ⧇, āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āĻāχ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋāϕ⧇ āϝ⧁āĻ•ā§āϤāĻŋāϏāĻ™ā§āĻ—āϤ āĻ“ āĻāϰ āĻāĻ•āϟāĻŋ āĻĢāϞāĻžāĻĢāϞ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ `1` āύāĻžāĻŽā§āĻŦāĻžāϰāϟāĻŋāϕ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇āϛ⧇āĨ¤ āύāĻžāĻŽā§āĻŦāĻžāϰ `1` āĻ“ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ `"2"` āĻāϰ āϝ⧋āϗ⧇āϰ āĻŦ⧇āϞāĻžā§Ÿ āύāĻžāĻŽā§āĻŦāĻžāϰāϟāĻŋāϕ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻšāĻŋāϏ⧇āĻŦ⧇ āϧāϰāĻž āĻšā§Ÿā§‡āϛ⧇āĨ¤ āφāĻŽāϰāĻž āĻĻ⧁āĻŸā§‹ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āϕ⧇ āϝ⧁āĻ•ā§āϤ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ āĻāĻ­āĻžāĻŦ⧇, `"Hello" + "World"`, āϤāĻžāχ āĻāĻ–āĻžāύ⧇ `"1" + "2"` āĻĢāϞāĻžāĻĢāϞ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇ `"12"`āĨ¤ +āĻāχ āωāĻĻāĻžāĻšāϰāύ⧇, āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āĻāχ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋāϕ⧇ āϝ⧁āĻ•ā§āϤāĻŋāϏāĻ™ā§āĻ—āϤ āĻ“ āĻāϰ āĻāĻ•āϟāĻŋ āĻĢāϞāĻžāĻĢāϞ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ `1` āύāĻžāĻŽā§āĻŦāĻžāϰāϟāĻŋāϕ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇āϛ⧇āĨ¤ āύāĻžāĻŽā§āĻŦāĻžāϰ `1` āĻ“ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ `"2"` āĻāϰ āϝ⧋āϗ⧇āϰ āĻŦ⧇āϞāĻžā§Ÿ āύāĻžāĻŽā§āĻŦāĻžāϰāϟāĻŋāϕ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻšāĻŋāϏ⧇āĻŦ⧇ āϧāϰāĻž āĻšā§Ÿā§‡āϛ⧇āĨ¤ āφāĻŽāϰāĻž āĻĻ⧁āĻŸā§‹ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āϕ⧇ āϝ⧁āĻ•ā§āϤ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ āĻāĻ­āĻžāĻŦ⧇, `"Hello" + "World"`, āϤāĻžāχ āĻāĻ–āĻžāύ⧇ `"1" + "2"` āĻĢāϞāĻžāĻĢāϞ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇ `"12"`āĨ¤

@@ -530,10 +528,12 @@ console.log(number); #### āωāĻ¤ā§āϤāϰ: C **āĻĒā§‹āĻ¸ā§āϟāĻĢāĻŋāĻ•ā§āϏ** āχāωāύāĻžāϰāĻŋ āĻ…āĻĒāĻžāϰ⧇āϟāϰ `++`: + 1. āĻĢāϞāĻžāĻĢāϞ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ (āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `0`) 2. āĻ­ā§āϝāĻžāϞ⧁āϰ āĻŽāĻžāύ āĻŦ⧃āĻĻā§āϧāĻŋ āĻ•āϰ⧇ (āύāĻžāĻŽā§āĻŦāĻžāϰāϟāĻŋ āĻāĻ–āύ `1`) **āĻĒā§āϰāĻŋāĻĢāĻŋāĻ•ā§āϏ** āχāωāύāĻžāϰāĻŋ āĻ…āĻĒāĻžāϰ⧇āϟāϰ `++`: + 1. āĻ­ā§āϝāĻžāϞ⧁āϰ āĻŽāĻžāύ āĻŦ⧃āĻĻā§āϧāĻŋ āĻ•āϰ⧇ (āύāĻžāĻŽā§āĻŦāĻžāϰāϟāĻŋ āĻāĻ–āύ `2`) 2. āĻĢāϞāĻžāĻĢāϞ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ (āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `2`) @@ -553,7 +553,7 @@ function getPersonInfo(one, two, three) { console.log(three); } -const person = "Lydia"; +const person = 'Lydia'; const age = 21; getPersonInfo`${person} is ${age} years old`; @@ -580,9 +580,9 @@ getPersonInfo`${person} is ${age} years old`; ```javascript function checkAge(data) { if (data === { age: 18 }) { - console.log("You are an adult!"); + console.log('You are an adult!'); } else if (data == { age: 18 }) { - console.log("You are still an adult."); + console.log('You are still an adult.'); } else { console.log(`Hmm.. You don't have an age I guess`); } @@ -631,7 +631,7 @@ getAge(21); #### āωāĻ¤ā§āϤāϰ: C -āĻāĻ–āĻžāύ⧇ āϰ⧇āĻ¸ā§āϟ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰāϟāĻŋ (`...args`) āφāĻŽāĻžāĻĻ⧇āϰāϕ⧇ āĻŦāĻžāĻ•āĻŋ āϏāĻŦ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟāϏāϕ⧇ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇āϤ⧇ "āϏāĻ‚āĻ—ā§āϰāĻš" āĻ•āϰāϤ⧇ āĻĻā§‡ā§ŸāĨ¤ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇ āĻšā§Ÿ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ, āϤāĻžāχ `typeof args` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `"object"`āĨ¤ +āĻāĻ–āĻžāύ⧇ āϰ⧇āĻ¸ā§āϟ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰāϟāĻŋ (`...args`) āφāĻŽāĻžāĻĻ⧇āϰāϕ⧇ āĻŦāĻžāĻ•āĻŋ āϏāĻŦ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟāϏāϕ⧇ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇āϤ⧇ "āϏāĻ‚āĻ—ā§āϰāĻš" āĻ•āϰāϤ⧇ āĻĻā§‡ā§ŸāĨ¤ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇ āĻšā§Ÿ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ, āϤāĻžāχ `typeof args` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `"object"`āĨ¤

@@ -642,7 +642,7 @@ getAge(21); ```javascript function getAge() { - "use strict"; + 'use strict'; age = 21; console.log(age); } @@ -670,7 +670,7 @@ getAge(); ###### 21. āϕ⧋āύāϟāĻŋ `sum` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻšāĻŦ⧇? ```javascript -const sum = eval("10*10+5"); +const sum = eval('10*10+5'); ``` - A: `105` @@ -683,7 +683,7 @@ const sum = eval("10*10+5"); #### āωāĻ¤ā§āϤāϰ: A -`eval` āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻšāĻŋāϏāĻžāĻŦ⧇ āĻĒāĻžāϏ āĻ•āϰāĻž āϕ⧋āĻĄāϕ⧇ āĻŽā§‚āĻ˛ā§āϝāĻžāϝāĻŧāύ āĻ•āϰ⧇āĨ¤ āϝāĻĻāĻŋ āĻāϟāĻŋ āĻāĻ•āϟāĻŋ āĻ…āĻ­āĻŋāĻŦā§āϝāĻ•ā§āϤāĻŋ (expression) āĻšāϝāĻŧ, āϝ⧇āĻŽāύ āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āĻāϟāĻŋ āĻ…āĻ­āĻŋāĻŦā§āϝāĻ•ā§āϤāĻŋ āĻŽā§‚āĻ˛ā§āϝāĻžāϝāĻŧāύ āĻ•āϰ⧇āϛ⧇āĨ¤ āĻ…āĻ­āĻŋāĻŦā§āϝāĻ•ā§āϤāĻŋāϟāĻŋ āĻšāϞ `10 * 10 + 5`āĨ¤ āĻāϟāĻŋ āĻĢāϞāĻžāĻĢāϞ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `105`āĨ¤ +`eval` āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻšāĻŋāϏāĻžāĻŦ⧇ āĻĒāĻžāϏ āĻ•āϰāĻž āϕ⧋āĻĄāϕ⧇ āĻŽā§‚āĻ˛ā§āϝāĻžāϝāĻŧāύ āĻ•āϰ⧇āĨ¤ āϝāĻĻāĻŋ āĻāϟāĻŋ āĻāĻ•āϟāĻŋ āĻ…āĻ­āĻŋāĻŦā§āϝāĻ•ā§āϤāĻŋ (expression) āĻšāϝāĻŧ, āϝ⧇āĻŽāύ āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āĻāϟāĻŋ āĻ…āĻ­āĻŋāĻŦā§āϝāĻ•ā§āϤāĻŋ āĻŽā§‚āĻ˛ā§āϝāĻžāϝāĻŧāύ āĻ•āϰ⧇āϛ⧇āĨ¤ āĻ…āĻ­āĻŋāĻŦā§āϝāĻ•ā§āϤāĻŋāϟāĻŋ āĻšāϞ `10 * 10 + 5`āĨ¤ āĻāϟāĻŋ āĻĢāϞāĻžāĻĢāϞ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `105`āĨ¤

@@ -693,7 +693,7 @@ const sum = eval("10*10+5"); ###### 22. āĻ•āϤāĻ•ā§āώāĻŖ cool_secret āĻāĻ•ā§āϏ⧇āϏāϝ⧋āĻ—ā§āϝ? ```javascript -sessionStorage.setItem("cool_secret", 123); +sessionStorage.setItem('cool_secret', 123); ``` - A: Forever, the data doesn't get lost. @@ -746,12 +746,12 @@ console.log(num); ###### 24. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const obj = { 1: "a", 2: "b", 3: "c" }; +const obj = { 1: 'a', 2: 'b', 3: 'c' }; const set = new Set([1, 2, 3, 4, 5]); -obj.hasOwnProperty("1"); +obj.hasOwnProperty('1'); obj.hasOwnProperty(1); -set.has("1"); +set.has('1'); set.has(1); ``` @@ -777,7 +777,7 @@ set.has(1); ###### 25. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const obj = { a: "one", b: "two", a: "three" }; +const obj = { a: 'one', b: 'two', a: 'three' }; console.log(obj); ``` @@ -835,7 +835,7 @@ for (let i = 1; i < 5; i++) { #### āωāĻ¤ā§āϤāϰ: C -`continue` āĻ¸ā§āĻŸā§‡āϟāĻŽā§‡āĻ¨ā§āϟ (āĻŦāĻŋāĻŦ⧃āϤāĻŋ) āĻāĻ•āϟāĻŋ āχāϟāĻžāϰ⧇āĻļāύ (āχāϟāĻžāϰ⧇āĻļāύ) āĻāĻĄāĻŧāĻŋāϝāĻŧ⧇ āϝāĻžāϝāĻŧ āϝāĻĻāĻŋ āĻāĻ•āϟāĻŋ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻļāĻ°ā§āϤ `true` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤ +`continue` āĻ¸ā§āĻŸā§‡āϟāĻŽā§‡āĻ¨ā§āϟ (āĻŦāĻŋāĻŦ⧃āϤāĻŋ) āĻāĻ•āϟāĻŋ āχāϟāĻžāϰ⧇āĻļāύ (āχāϟāĻžāϰ⧇āĻļāύ) āĻāĻĄāĻŧāĻŋāϝāĻŧ⧇ āϝāĻžāϝāĻŧ āϝāĻĻāĻŋ āĻāĻ•āϟāĻŋ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻļāĻ°ā§āϤ `true` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤

@@ -846,10 +846,10 @@ for (let i = 1; i < 5; i++) { ```javascript String.prototype.giveLydiaPizza = () => { - return "Just give Lydia pizza already!"; + return 'Just give Lydia pizza already!'; }; -const name = "Lydia"; +const name = 'Lydia'; console.log(name.giveLydiaPizza()); ``` @@ -877,8 +877,8 @@ console.log(name.giveLydiaPizza()); ```javascript const a = {}; -const b = { key: "b" }; -const c = { key: "c" }; +const b = { key: 'b' }; +const c = { key: 'c' }; a[b] = 123; a[c] = 456; @@ -896,11 +896,11 @@ console.log(a[b]); #### āωāĻ¤ā§āϤāϰ: B -Object keys are automatically converted into strings. We are trying to set an object as a key to object `a`, with the value of `123`. +āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻ•āĻŋāϗ⧁āϞ⧋ āĻ¸ā§āĻŦ⧟āĻ‚āĻ•ā§āϰāĻŋ⧟āĻ­āĻžāĻŦ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻšā§Ÿā§‡ āϝāĻžā§ŸāĨ¤ āφāĻŽāϰāĻž `123` āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻĻāĻŋā§Ÿā§‡ `a` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻ•āĻŋ āĻšāĻŋāϏ⧇āĻŦ⧇ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇āχ āϕ⧇ āϏ⧇āϟ āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāĻ›āĻŋāĨ¤ -However, when we stringify an object, it becomes `"[object Object]"`. So what we are saying here, is that `a["[object Object]"] = 123`. Then, we can try to do the same again. `c` is another object that we are implicitly stringifying. So then, `a["[object Object]"] = 456`. +āϝāĻžāχāĻšā§‹āĻ•, āϝāĻ–āύ āφāĻŽāϰāĻž āϕ⧋āύ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āĻĢāĻžāχ āĻ•āϰāĻŋ āϤāĻ–āύ āϏ⧇āϟāĻŋ `"[object Object]"` āĻšā§Ÿā§‡ āϝāĻžā§ŸāĨ¤ āϤāĻžāĻšāϞ⧇ āĻāĻ–āĻžāύ⧇ āφāĻŽāϰāĻž āϝāĻž āĻŦāϞāĻ›āĻŋ āϏ⧇āϟāĻŋ āĻšāϞ, `a["[object Object]"] = 123`āĨ¤ āϤāĻžāϰāĻĒāϰ āφāĻŽāϰāĻž āĻāĻ•āĻŋ āĻ•āĻžāϜ āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰ⧇āĻ›āĻŋāĨ¤ `c` āĻšāϞ āĻ…āĻ¨ā§āϝ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āϝ⧇āϟāĻžāϕ⧇ āφāĻŽāϰāĻž āĻĒāϰ⧋āĻ•ā§āώāĻ­āĻžāĻŦ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āĻĢāĻžāχ āĻ•āϰāĻ›āĻŋāĨ¤ āϤāĻžāĻšāϞ⧇, `a["[object Object]"] = 456`āĨ¤ -Then, we log `a[b]`, which is actually `a["[object Object]"]`. We just set that to `456`, so it returns `456`. +āϤāĻžāϰāĻĒāϰ āφāĻŽāϰāĻž `a[b]` āϞāĻ— āĻ•āϰāĻŋ, āϝ⧇āϟāĻž āφāϏāϞ⧇ `a["[object Object]"]`āĨ¤ āφāĻŽāϰāĻž āϕ⧇āĻŦāϞāχ āĻāϟāĻžāϕ⧇ āϏ⧇āϟ āĻ•āϰ⧇āĻ›āĻŋ `456`, āϤāĻžāχ āĻāϟāĻž āĻĢāϞāĻžāĻĢāϞ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇ `456`āĨ¤

@@ -910,9 +910,9 @@ Then, we log `a[b]`, which is actually `a["[object Object]"]`. We just set that ###### 30. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const foo = () => console.log("First"); -const bar = () => setTimeout(() => console.log("Second")); -const baz = () => console.log("Third"); +const foo = () => console.log('First'); +const bar = () => setTimeout(() => console.log('Second')); +const baz = () => console.log('Third'); bar(); foo(); @@ -929,38 +929,38 @@ baz(); #### āωāĻ¤ā§āϤāϰ: B -We have a `setTimeout` function and invoked it first. Yet, it was logged last. +āφāĻŽāĻžāĻĻ⧇āϰ āĻāĻ•āϟāĻŋ `setTimeout` āĻĢāĻžāĻ‚āĻļāύ āφāϛ⧇ āĻāĻŦāĻ‚ āĻāϟāĻŋāχ āφāϗ⧇ āĻ•āϞ āĻšā§Ÿā§‡āϛ⧇āĨ¤ āϤāĻŦ⧁ āĻāϟāĻŋ āĻļ⧇āώ⧇ āϞāĻ— āĻšā§Ÿā§‡āϛ⧇āĨ¤ -This is because in browsers, we don't just have the runtime engine, we also have something called a `WebAPI`. The `WebAPI` gives us the `setTimeout` function to start with, and for example the DOM. +āĻāϰ āĻ•āĻžāϰāύ āĻšāϞ āĻŦā§āϰāĻžāωāϜāĻžāϰ⧇ āϕ⧇āĻŦāϞ āϰāĻžāύāϟāĻžāχāĻŽ āχāĻžā§āϜāĻŋāύāχ āύ⧇āχ, āφāĻŽāĻžāĻĻ⧇āϰ āĻ•āĻžāϛ⧇ `WebAPI` āύāĻžāĻŽā§‡āĻ“ āĻ•āĻŋāϛ⧁ āĻāĻ•āϟāĻž āϜāĻŋāύāĻŋāϏ āφāϛ⧇āĨ¤ āĻāχ `WebAPI`-āχ āφāĻŽāĻžāĻĻ⧇āϰ āĻļ⧁āϰ⧁ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ `setTimeout` āĻĢāĻžāĻ‚āĻļāύ āĻĻā§‡ā§Ÿ, āĻāĻŦāĻ‚ āωāĻĻāĻžāĻšāϰāĻŖāĻ¸ā§āĻŦāϰ⧂āĻĒ DOMāĨ¤ -After the _callback_ is pushed to the WebAPI, the `setTimeout` function itself (but not the callback!) is popped off the stack. +_āĻ•āϞāĻŦā§āϝāĻžāĻ•_ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋāϕ⧇ WebAPI āĻ āĻĒ⧁āĻļ āĻ•āϰāĻžāϰ āĻĒāϰ `setTimeout` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āύāĻŋāĻœā§‡āχ āĻ•āϞ āĻ¸ā§āĻŸā§āϝāĻžāĻ• āĻĨ⧇āϕ⧇ āĻĒāĻĒ āĻšā§Ÿā§‡ āϝāĻžā§ŸāĨ¤ -Now, `foo` gets invoked, and `"First"` is being logged. +āĻāĻ–āύ `foo` āϕ⧇ āĻ•āϞ āĻ•āϰāĻž āĻšāĻšā§āϛ⧇ āĻāĻŦāĻ‚ `"First"` āϞāĻ— āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇āĨ¤ -`foo` is popped off the stack, and `baz` gets invoked. `"Third"` gets logged. +āĻ•āϞ āĻ¸ā§āĻŸā§āϝāĻžāĻ• āĻĨ⧇āϕ⧇ `foo` āĻĒāĻĒ āĻšā§Ÿā§‡ āϝāĻžā§Ÿ, āĻāĻŦāĻ‚ `baz` āĻ•āϞ āĻ•āϰāĻž āĻšā§ŸāĨ¤ `"Third"` āϞāĻ— āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇āĨ¤ -The WebAPI can't just add stuff to the stack whenever it's ready. Instead, it pushes the callback function to something called the _queue_. +`WebAPI` āĻĒā§āϰāĻ¸ā§āϤ⧁āϤ āĻšāϞ⧇āχ āϏ⧇ āĻ•āϞ āĻ¸ā§āĻŸā§āϝāĻžāϕ⧇ āĻ•āĻŋāϛ⧁ āϝ⧁āĻ•ā§āϤ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇ āύāĻžāĨ¤ āϤāĻžāϰ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤ⧇ āϏ⧇ āĻ•āϞāĻŦā§āϝāĻžāĻ• āĻĢāĻžāĻ‚āĻļāύ āϗ⧁āϞāĻŋāϕ⧇ āϟāĻžāĻ¸ā§āĻ• āĻ•āĻŋāω āύāĻžāĻŽāĻ• āĻ•āĻŋāϛ⧁āϤ⧇ āĻĒ⧁āĻļ āĻ•āϰ⧇ āĻĻā§‡ā§ŸāĨ¤ -This is where an event loop starts to work. An **event loop** looks at the stack and task queue. If the stack is empty, it takes the first thing on the queue and pushes it onto the stack. +āĻāĻ–āĻžāύ⧇āχ āĻāĻ•āϟāĻŋ _āχāϭ⧇āĻ¨ā§āϟ āϞ⧁āĻĒ_ āĻ•āĻžāϜ āĻ•āϰāϤ⧇ āĻļ⧁āϰ⧁ āĻ•āϰ⧇āĨ¤ āĻāĻ•āϟāĻŋ _āχāϭ⧇āĻ¨ā§āϟ āϞ⧁āĻĒ_ āĻ•āϞ āĻ¸ā§āĻŸā§āϝāĻžāĻ• āĻ“ āϟāĻžāĻ¸ā§āĻ• āĻ•āĻŋāωāϰ āĻĻāĻŋāϕ⧇ āύāϜāϰ āϰāĻžāϖ⧇āĨ¤ āϝāĻĻāĻŋ āĻ¸ā§āĻŸā§āϝāĻžāĻ• āĻ–āĻžāϞāĻŋ āĻĨāĻžāϕ⧇ āĻāϟāĻž āĻ•āĻŋāω āĻĨ⧇āϕ⧇ ā§§āĻŽ āϜāĻŋāύāĻŋāϏāϟāĻžāϕ⧇ āύāĻŋā§Ÿā§‡ āĻ¸ā§āĻŸā§āϝāĻžāϕ⧇ āĻĒ⧁āĻļ āĻ•āϰ⧇ āĻĻā§‡ā§ŸāĨ¤ -`bar` gets invoked, `"Second"` gets logged, and it's popped off the stack. +`bar` āĻ•āϞ āĻ•āϰāĻž āĻšā§Ÿā§‡, āϤāĻžāχ `"Second"` āϞāĻ— āĻšā§Ÿā§‡āϛ⧇, āĻāĻŦāĻ‚ āĻāϟāĻž āĻ¸ā§āĻŸā§āϝāĻžāĻ• āĻĨ⧇āϕ⧇ āĻĒāĻĒ āĻšā§Ÿā§‡ āϝāĻžā§ŸāĨ¤

--- -###### 31. What is the event.target when clicking the button? +###### 31. āĻŦāĻžāϟāύ⧇ āĻ•ā§āϞāĻŋāĻ• āĻ•āϰāϞ⧇ event.target āϕ⧋āύāϟāĻŋ āĻšāĻŦ⧇? ```html
@@ -980,14 +980,14 @@ This is where an event loop starts to work. An **event loop** looks at the stack #### āωāĻ¤ā§āϤāϰ: C -The deepest nested element that caused the event is the target of the event. You can stop bubbling by `event.stopPropagation` +āχāϭ⧇āĻ¨ā§āĻŸā§‡āϰ āϟāĻžāĻ°ā§āϗ⧇āϟ āĻšāĻšā§āϛ⧇ āĻĄāĻŽā§‡āϰ āĻ—āĻ­ā§€āϰāϤāĻŽ āύ⧇āĻ¸ā§āĻŸā§‡āĻĄ āĻāϞāĻŋāĻŽā§āϝāĻžāĻ¨ā§āϟ āϝ⧇ āχāύāϭ⧇āύāϟāĻŋ āϘāϟāĻŋā§Ÿā§‡āϛ⧇āĨ¤

--- -###### 32. When you click the paragraph, what's the logged output? +###### 32. āϝāĻ–āύ āĻĒā§āϝāĻžāϰāĻžāĻ—ā§āϰāĻžāĻĢ⧇ āĻ•ā§āϞāĻŋāĻ• āĻ•āϰāĻŦ⧇āύ, āϞāĻ— āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻŋ āĻšāĻŦ⧇? ```html
@@ -1007,6 +1007,9 @@ The deepest nested element that caused the event is the target of the event. You If we click `p`, we see two logs: `p` and `div`. During event propagation, there are 3 phases: capturing, targeting, and bubbling. By default, event handlers are executed in the bubbling phase (unless you set `useCapture` to `true`). It goes from the deepest nested element outwards. +`p` āϤ⧇ āĻ•ā§āϞāĻŋāĻ• āĻ•āϰāϞ⧇āχ āφāĻŽāϰāĻž ⧍āϟāĻž āϞāĻ— āĻĻ⧇āĻ–āϤ⧇ āĻĒāĻžāχāσ `p` āĻ“ `div`āĨ¤ +āχāϭ⧇āĻ¨ā§āϟ āĻĒā§āϰ⧋āĻĒāĻžāϗ⧇āĻļāύ āĻāϰ āϏāĻŽā§Ÿ ā§ŠāϟāĻž āĻĒāĻ°ā§āϝāĻžā§Ÿ āĻĨāĻžāϕ⧇ āĻ•ā§āϝāĻžāĻĒāϚāĻžāϰāĻŋāĻ‚, āϟāĻžāϰāϗ⧇āϟāĻŋāĻ‚, āĻ“ āĻŦāĻžāĻŦāϞāĻŋāĻ‚āĨ¤ āĻ¸ā§āĻŦāĻžāĻŦāĻžāĻŦāĻŋāĻ•āĻ­āĻžāĻŦ⧇āχ āχāϭ⧇āĻ¨ā§āϟ āĻšā§āϝāĻžāĻ¨ā§āĻĄāϞāĻžāϰāϗ⧁āϞ⧋ āĻ•āĻžāϜ āĻ•āϰ⧇ āĻŦāĻžāĻŦāϞāĻŋāĻ‚ āĻĒāĻ°ā§āϝāĻžā§Ÿā§‡ (āϝāĻĻāĻŋ āύāĻž āφāĻĒāύāĻŋ `capture` āϕ⧇ `true` āĻ•āϰ⧇ āĻĻ⧇āύ)āĨ¤ āĻāϟāĻž āĻ—āĻ­ā§€āϰāϤāĻŽ āύ⧇āĻ¸ā§āĻŸā§‡āĻĄ āĻāϞāĻŋāĻŽā§āϝāĻžāĻ¨ā§āϟ āĻĨ⧇āϕ⧇ āĻŦāĻžāĻšāĻŋāϰ⧇āϰ (āĻĒā§āϝāĻžāϰ⧇āĻ¨ā§āĻŸā§‡āϰ) āĻĻāĻŋāϕ⧇ āϝāĻžā§ŸāĨ¤ +

@@ -1015,7 +1018,7 @@ If we click `p`, we see two logs: `p` and `div`. During event propagation, there ###### 33. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const person = { name: "Lydia" }; +const person = { name: 'Lydia' }; function sayHi(age) { return `${this.name} is ${age}`; @@ -1035,9 +1038,9 @@ console.log(sayHi.bind(person, 21)); #### āωāĻ¤ā§āϤāϰ: D -With both, we can pass the object to which we want the `this` keyword to refer to. However, `.call` is also _executed immediately_! +`.call` āĻ“ `.bind` āĻĻ⧁āϟāĻŋ āĻĻāĻŋā§Ÿā§‡āχ āφāĻŽāϰāĻž `this` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄāϟāĻŋ āϰ⧇āĻĢāĻžāϰ āĻ•āϰāĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻĒāĻžāϏ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ āĻ•āĻŋāĻ¨ā§āϤ⧁ `.call` āĻāĻ•āχ āϏāĻžāĻĨ⧇ āĻ•āϞāĻ“ āĻšā§Ÿā§‡ āϝāĻžāĻšā§āϛ⧇āĨ¤ -`.bind.` returns a _copy_ of the function, but with a bound context! It is not executed immediately. +`.bind.` āĻāϰ āĻŦ⧇āϞāĻžā§Ÿ āϏ⧇ _āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āĻ•āĻĒāĻŋ_'āϰ āϏāĻžāĻĨ⧇ `this` āĻāϰ āĻāĻ•āϟāĻŋ āĻ•āĻžāĻ°ā§āϝāĻ•āϰ (bound) āĻ•āύāĻŸā§āϝāĻžāĻ•ā§āϏ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤ āĻ•āĻŋāĻ¨ā§āϤ⧁ āĻāĻ•āχ āϏāĻžāĻĨ⧇ āĻ•āϞ āĻšā§Ÿ āύāĻžāĨ¤

@@ -1064,21 +1067,22 @@ console.log(typeof sayHi()); #### āωāĻ¤ā§āϤāϰ: B -The `sayHi` function returns the returned value of the immediately invoked function expression (IIFE). This function returned `0`, which is type `"number"`. -FYI: `typeof` can return the following list of values: `undefined`, `boolean`, `number`, `bigint`, `string`, `symbol`, `function` and `object`. Note that `typeof null` returns `"object"`. +`sayHi` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āχāĻŽāĻŋāĻĄāĻŋā§Ÿā§‡āϟāϞāĻŋ āχāύāĻ­ā§‹āĻ•āĻĄ āĻĢāĻžāĻ‚āĻļāύ āĻāĻ•ā§āϏāĻĒā§āϰ⧇āĻļāύ⧇āϰ (IIFE) āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋāχ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇āĨ¤ āĻāχ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āϛ⧇ `0` āϝ⧇āϟāĻŋāϰ āϟāĻžāχāĻĒ āĻšāĻšā§āϛ⧇ āĻāĻ•āϟāĻŋ `"number"`āĨ¤ + +> āĻœā§‡āύ⧇ āϰāĻžāϖ⧁āύāσ `typeof` āϞāĻŋāĻ¸ā§āĻŸā§‡ āωāĻ˛ā§āϞ⧇āĻ–āĻŋāϤ āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞ⧋ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āσ `undefined`, `boolean`, `number`, `bigint`, `string`, `symbol`, `function` āĻāĻŦāĻ‚ `object`āĨ¤ āĻŽāύ⧇ āϰāĻžāĻ–āĻŦ⧇āύ āϝ⧇ `typeof null` āĻ•āĻŋāĻ¨ā§āϤ⧁ `"object"` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤

--- -###### 35. Which of these values are falsy? +###### 35. āϕ⧋āύ āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞ⧋ āĻŽāĻŋāĻĨā§āϝāĻž āĻšā§Ÿ? ```javascript 0; new Number(0); -(""); -(" "); +(''); +(' '); new Boolean(false); undefined; ``` @@ -1093,7 +1097,7 @@ undefined; #### āωāĻ¤ā§āϤāϰ: A -There are 8 falsy values: +āĻŽā§‹āϟ ā§Ž āϰāĻ•āĻŽā§‡āϰ āĻŽāĻŋāĻĨā§āϝāĻž āĻ­ā§āϝāĻžāϞ⧁ āĻšā§Ÿāσ - `undefined` - `null` @@ -1104,7 +1108,7 @@ There are 8 falsy values: - `-0` - `0n` (BigInt(0)) -Function constructors, like `new Number` and `new Boolean` are truthy. +āĻĢāĻžāĻ‚āĻļāύ āĻ•āĻ¨ā§āϏāĻŸā§āϰāĻžāĻ•ā§āϟāϰāϗ⧁āϞ⧋, āϝ⧇āĻŽāύ `new Number` āĻ“ `new Boolean` āϏāĻŦāϏāĻŽā§Ÿ āϏāĻ¤ā§āϝ āĻšā§ŸāĨ¤ āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āĻŸā§‡ āĻĢāĻžāĻ‚āĻļāύāϗ⧁āϞ⧋ āĻšā§Ÿ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻāĻŦāĻ‚ āĻāϰāĻž āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āϟāĻžāχāĻĒāĨ¤ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āϟāĻžāχāĻĒ āĻ•āĻ–āύ⧋ āĻŽāĻŋāĻĨā§āϝāĻž āĻšā§Ÿ āύāĻžāĨ¤

@@ -1127,8 +1131,8 @@ console.log(typeof typeof 1); #### āωāĻ¤ā§āϤāϰ: B -`typeof 1` returns `"number"`. -`typeof "number"` returns `"string"` +`typeof 1` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `"number"`. +āφāϰ `typeof "number"` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `"string"`

@@ -1153,11 +1157,11 @@ console.log(numbers); #### āωāĻ¤ā§āϤāϰ: C -When you set a value to an element in an array that exceeds the length of the array, JavaScript creates something called "empty slots". These actually have the value of `undefined`, but you will see something like: +āφāĻĒāύāĻŋ āϝāĻ–āύ āĻ…ā§āϝāĻžāϰ⧇āϰ āĻāĻŽāύ āϕ⧋āύ āχāύāĻĄā§‡āĻ•ā§āϏ⧇ āĻāĻ•āϟāĻŋ āĻ­ā§āϝāĻžāϞ⧁ āϏ⧇āϟ āĻ•āϰ⧇āύ āϝ⧇āϟāĻž āĻ…ā§āϝāĻžāϰ⧇āϰ āĻĻ⧈āĻ°ā§āĻ˜ā§āϝāϕ⧇ āĻ…āϤāĻŋāĻ•ā§āϰāĻŽ āĻ•āϰ⧇ āĻĢ⧇āϞ⧇, āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āϤāĻ–āύ "empty slots" āύāĻžāĻŽā§‡ āĻ•āĻŋāϛ⧁ āϤāĻŋāϰāĻŋ āĻ•āϰ⧇āĨ¤ āĻāϟāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁ āφāϏāϞ⧇ `undefined` āĻ•āĻŋāĻ¨ā§āϤ⧁ āφāĻĒāύāĻŋ āĻĻ⧇āĻ–āϤ⧇ āĻĒāĻžāĻŦ⧇āύ āĻāĻŽāύ āĻ•āĻŋāϛ⧁āσ `[1, 2, 3, empty x 7, 11]` -depending on where you run it (it's different for every browser, node, etc.) +āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āϕ⧋āĻĨāĻžā§Ÿ āϚāϞāϛ⧇ āϤāĻžāϰ āωāĻĒāϰ āĻ­āĻŋāĻ¤ā§āϤāĻŋ āĻ•āϰ⧇ (āĻāϟāĻž āĻĒā§āϰāϤāĻŋāϟāĻŋ āĻŦā§āϰāωāϜāĻžāϰ, āύ⧋āĻĄ āχāĻ¤ā§āϝāĻžāĻĻāĻŋāϰ āϜāĻ¨ā§āϝ āφāϞāĻžāĻĻāĻž)

@@ -1190,18 +1194,18 @@ depending on where you run it (it's different for every browser, node, etc.) #### āωāĻ¤ā§āϤāϰ: A -The `catch` block receives the argument `x`. This is not the same `x` as the variable when we pass arguments. This variable `x` is block-scoped. +`catch` āĻŦā§āϞāĻ•āϟāĻŋ āĻāĻ•āϟāĻŋ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ `x` āϰāĻŋāϏāĻŋāĻ­ āĻ•āϰ⧇āϛ⧇āĨ¤ āφāĻŽāϰāĻž āϝāĻ–āύ āφāĻ°ā§āϗ⧁āĻŽā§‡āϟāϏ āĻĒāĻžāϏ āĻ•āϰāĻ›āĻŋ āĻāϟāĻž āφāϰ `x` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞ āĻāĻ•āχ āύ⧟āĨ¤ āĻāχ `x` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞāϟāĻŋ āĻšāϞ āĻŦā§āϞāĻ•-āĻ¸ā§āϕ⧋āĻĒāĻĄāĨ¤ -Later, we set this block-scoped variable equal to `1`, and set the value of the variable `y`. Now, we log the block-scoped variable `x`, which is equal to `1`. +āĻĒāϰāĻŦāĻ°ā§āϤ⧀āϤ⧇, āφāĻŽāϰāĻž āĻŦā§āϞāĻ•-āĻ¸ā§āϕ⧋āĻĒāĻĄ āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞāϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁ āϏ⧇āϟ āĻ•āϰāĻ›āĻŋ `1` āĻāĻŦāĻ‚ `y` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞāϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁ āϏ⧇āϟ āĻ•āϰāĻ›āĻŋ `2`āĨ¤ āĻāĻ–āύ, āφāĻŽāϰāĻž āϞāĻ— āĻ•āϰāĻ›āĻŋ āĻŦā§āϞāĻ•-āĻ¸ā§āϕ⧋āĻĒāĻĄ `x` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞāϟāĻŋ, āϝ⧇āϟāĻž āϏāĻŽāĻžāύ āĻšāϞ `1`āĨ¤ -Outside of the `catch` block, `x` is still `undefined`, and `y` is `2`. When we want to `console.log(x)` outside of the `catch` block, it returns `undefined`, and `y` returns `2`. +āĻ•ā§āϝāĻžāϚ-āĻŦā§āϞāϕ⧇āϰ āĻŦāĻžāχāϰ⧇ `x` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞāϟāĻŋ āĻāĻ–āύ⧋ `undefined` āĻāĻŦāĻ‚ `y` āĻšāϞ `2`āĨ¤ āϝāĻ–āύ āĻ•ā§āϝāĻžāϚ-āĻŦā§āϞāϕ⧇āϰ āĻŦāĻžāχāϰ⧇ `console.log(x)` āĻ•āϰāϤ⧇ āϚāĻžāĻšā§āĻ›āĻŋ, āĻāϟāĻž āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `undefined`, āĻāĻŦāĻ‚ `y` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `2`āĨ¤

--- -###### 39. Everything in JavaScript is either a... +###### 39. āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āĻŸā§‡ āϏāĻŦāĻ•āĻŋāϛ⧁āχ āĻšā§Ÿ āĻāĻ•āϟāĻŋ ...... āĨ¤ - A: primitive or object - B: function or object @@ -1213,11 +1217,11 @@ Outside of the `catch` block, `x` is still `undefined`, and `y` is `2`. When we #### āωāĻ¤ā§āϤāϰ: A -JavaScript only has primitive types and objects. +āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āĻŸā§‡ āφāϛ⧇ āϕ⧇āĻŦāϞ āĻĒā§āϰāĻŋāĻŽāĻŋāϟāĻŋāĻ­ (āĻŽā§ŒāϞāĻŋāĻ•) āϟāĻžāχāĻĒ āĻ“ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāĨ¤ -Primitive types are `boolean`, `null`, `undefined`, `bigint`, `number`, `string`, and `symbol`. +āĻĒā§āϰāĻŋāĻŽāĻŋāϟāĻŋāĻ­ (āĻŽā§ŒāϞāĻŋāĻ•) āϟāĻžāχāĻĒāϗ⧁āϞ⧋ āĻšāϞ - `boolean`, `null`, `undefined`, `bigint`, `number`, `string`, āĻ“ `symbol`āĨ¤ -What differentiates a primitive from an object is that primitives do not have any properties or methods; however, you'll note that `'foo'.toUpperCase()` evaluates to `'FOO'` and does not result in a `TypeError`. This is because when you try to access a property or method on a primitive like a string, JavaScript will implicitly wrap the primitive type using one of the wrapper classes, i.e. `String`, and then immediately discard the wrapper after the expression evaluates. All primitives except for `null` and `undefined` exhibit this behavior. +āĻĒā§āϰāĻŋāĻŽāĻŋāϟāĻŋāĻ­ āϟāĻžāχāĻĒ⧇āϰ āϕ⧋āύ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϏ/āĻŽā§‡āĻĨāĻĄ āύ⧇āχ āĻāϟāĻžāχ āĻāĻ•āϟāĻŋ āĻĒā§āϰāĻŋāĻŽāĻŋāϟāĻŋāĻ­ āϟāĻžāχāĻĒāϕ⧇ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻĨ⧇āϕ⧇ āφāϞāĻžāĻĻāĻž āĻ•āϰ⧇āϛ⧇; āĻ…āĻ¨ā§āϝāĻĻāĻŋāϕ⧇ āφāĻĒāύāĻŋ āĻ–ā§‡ā§ŸāĻžāϞ āĻ•āϰāĻŦ⧇āύ āϝ⧇ `'foo'.toUpperCase()` āĻ—āύāύāĻž āĻ•āϰāϛ⧇ `'FOO'` āĻāĻŦāĻ‚ āϕ⧋āύ `TypeError`āĻ“ āĻĻā§‡ā§Ÿ āύāĻžāĨ¤ āĻāϟāĻžāϰ āĻ•āĻžāϰāύ āĻšāϞ, āφāĻĒāύāĻŋ āϝāĻ–āύ āϕ⧋āύ āĻĒā§āϰāĻŋāĻŽāĻŋāϟāĻŋāĻ­ āϟāĻžāχāĻĒ āϝ⧇āĻŽāύ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻĻāĻŋā§Ÿā§‡ āϕ⧋āύ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϏ/āĻŽā§‡āĻĨāĻĄ āϕ⧇ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāϤ⧇ āϚāĻžāĻšā§āϛ⧇āύ, āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āϤāĻ–āύ āĻĒā§āϰāĻŋāĻŽāĻŋāϟāĻŋāĻ­ āϟāĻžāχāĻĒāϕ⧇ āĻ°â€ā§āϝāĻžāĻĒāĻžāϰ āĻ•ā§āϞāĻžāϏāϗ⧁āϞ⧋āϰ āĻāĻ•āϟāĻŋ āϝ⧇āĻŽāύ, `String` āĻĻāĻŋā§Ÿā§‡ āĻŽā§ā§œā§‡ āĻĻā§‡ā§Ÿ, āĻāĻŦāĻ‚ āĻŽāĻžāύ āĻ—āύāύāĻž āĻšā§Ÿā§‡ āϝāĻžāĻ“ā§ŸāĻžāϰ āϏāĻžāĻĨ⧇ āϏāĻžāĻĨ⧇āχ āϏ⧇āϟāĻŋ āĻŦāĻžāϤāĻŋāϞ āĻšā§Ÿā§‡ āϝāĻžā§ŸāĨ¤ `null` āĻ“ `undefined` āĻŦāĻžāĻĻ⧇ āϏāĻ•āϞ āĻĒā§āϰāĻŋāĻŽāĻŋāϟāĻŋāĻ­āχ āĻāĻ•āχ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻĒā§āϰāĻĻāĻ°ā§āĻļāύ āĻ•āϰ⧇āĨ¤

@@ -1248,9 +1252,9 @@ What differentiates a primitive from an object is that primitives do not have an #### āωāĻ¤ā§āϤāϰ: C -`[1, 2]` is our initial value. This is the value we start with, and the value of the very first `acc`. During the first round, `acc` is `[1,2]`, and `cur` is `[0, 1]`. We concatenate them, which results in `[1, 2, 0, 1]`. +āĻāĻ–āĻžāύ⧇ `[1, 2]` āφāĻŽāĻžāĻĻ⧇āϰ āĻĒā§āϰāĻĨāĻŽāĻŋāĻ• āĻ­ā§āϝāĻžāϞ⧁āĨ¤ āĻāχ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻĻāĻŋā§Ÿā§‡āχ āφāĻŽāϰāĻž āĻļ⧁āϰ⧁ āĻ•āϰāĻŦ āĻāĻŦāĻ‚ āĻāϟāĻžāχ `acc` āĻāϰ ā§§āĻŽ āĻ­ā§āϝāĻžāϞ⧁āĨ¤ ā§§āĻŽ āϰāĻžāωāĻ¨ā§āĻĄā§‡āϰ āϏāĻŽā§Ÿ, `acc` āĻšā§Ÿ `[1,2]`, āĻāĻŦāĻ‚ `cur` āĻšā§Ÿ `[0, 1]`āĨ¤ āφāĻŽāϰāĻž āϤāĻžāĻĻ⧇āϰāϕ⧇ āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻ›āĻŋ, āϝ⧇āϟāĻžāϰ āĻĢāϞāĻžāĻĢāϞ āĻšāϞ `[1, 2, 0, 1]`āĨ¤ -Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and get `[1, 2, 0, 1, 2, 3]` +āĻĒāϰāĻŦāĻ°ā§āϤ⧀āϤ⧇ ⧍⧟/āĻļ⧇āώ āϧāĻžāĻĒ⧇, `acc` āĻšā§Ÿ `[1, 2, 0, 1]` āĻāĻŦāĻ‚ `cur` āĻšā§Ÿ `[2, 3]`, āφāĻŽāϰāĻž āϤāĻžāĻĻ⧇āϰāϕ⧇ āϝ⧁āĻ•ā§āϤ āĻ•āϰ⧇ āĻĢāϞāĻžāĻĢāϞ āĻĒāĻžāĻšā§āĻ›āĻŋ `[1, 2, 0, 1, 2, 3]`āĨ¤

@@ -1261,7 +1265,7 @@ Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and ge ```javascript !!null; -!!""; +!!''; !!1; ``` @@ -1275,21 +1279,23 @@ Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and ge #### āωāĻ¤ā§āϤāϰ: B -`null` is falsy. `!null` returns `true`. `!true` returns `false`. +`null` āĻšāϞ āĻŽāĻŋāĻĨā§āϝāĻžāĨ¤ `!null` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `true`āĨ¤ `!true` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `false`. + +`""` āĻšāϞ āĻŽāĻŋāĻĨā§āϝāĻžāĨ¤ `!""` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `true`āĨ¤ `!true` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `false`āĨ¤ -`""` is falsy. `!""` returns `true`. `!true` returns `false`. +`1` āĻšāϞ āϏāĻ¤ā§āϝāĨ¤ `!1` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `false`āĨ¤ `!false` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `true`āĨ¤ -`1` is truthy. `!1` returns `false`. `!false` returns `true`. +āϤāĻžāχ āϏāĻ āĻŋāĻ• āĻšāϞ - `false` `false` `true`āĨ¤

--- -###### 42. What does the `setInterval` method return in the browser? +###### 42. āĻāχ `setInterval` āĻŽā§‡āĻĨāĻĄāϟāĻŋ āĻŦā§āϰāĻžāωāϜāĻžāϰ⧇ āĻ•āĻŋ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇? ```javascript -setInterval(() => console.log("Hi"), 1000); +setInterval(() => console.log('Hi'), 1000); ``` - A: a unique id @@ -1302,17 +1308,17 @@ setInterval(() => console.log("Hi"), 1000); #### āωāĻ¤ā§āϤāϰ: A -It returns a unique id. This id can be used to clear that interval with the `clearInterval()` function. +āϝāĻĻāĻŋāĻ“ āĻāϟāĻŋ āĻŦāĻžāωāϜāĻžāϰ⧇ ā§§ āϏ⧇āϕ⧇āĻ¨ā§āĻĄ āĻĒāϰ āĻĒāϰ `'Hi'` āϞāĻ— āĻ•āϰ⧇āχ āϝāĻžāĻŦ⧇ āĻ•āĻŋāĻ¨ā§āϤ⧁ `setInterval` āĻŽā§‡āĻĨāĻĄāϟāĻŋ āĻāĻ•āϟāĻŋ āĻ…āύāĻ¨ā§āϝ āφāχāĻĄāĻŋ (unique id) āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤ āĻāχ āĻĒ⧁āĻ°ā§āϝāĻžā§ŸāĻ•ā§āϰāĻŽāĻŋāĻ• āĻ•āĻžāϜāϕ⧇ `clearInterval()` āĻĻāĻŋā§Ÿā§‡ āĻŽā§āϛ⧇ āĻĢ⧇āϞāϤ⧇ āϐ āφāχāĻĄāĻŋ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāĻž āĻšā§ŸāĨ¤

--- -###### 43. What does this return? +###### 43. āĻāϟāĻž āĻ•āĻŋ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇? ```javascript -[..."Lydia"]; +[...'Lydia']; ``` - A: `["L", "y", "d", "i", "a"]` @@ -1325,7 +1331,7 @@ It returns a unique id. This id can be used to clear that interval with the `cle #### āωāĻ¤ā§āϤāϰ: A -A string is an iterable. The spread operator maps every character of an iterable to one element. +āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻāĻ•āϟāĻŋ āĻĒ⧁āύāϰāĻžāĻŦ⧃āĻ¤ā§āϤāĻŋāϝ⧋āĻ—ā§āϝ āϟāĻžāχāĻĒāĨ¤ āĻ¸ā§āĻĒā§āϰ⧇āĻĄ āĻ…āĻĒāĻžāϰ⧇āϟāϰ āĻĒ⧁āύāϰāĻžāĻŦ⧃āĻ¤ā§āϤāĻŋāϝ⧋āĻ—ā§āϝ āĻĒā§āϰāϤāĻŋāϟāĻŋ āĻ…āĻ•ā§āώāϰāϕ⧇ āĻŽā§āϝāĻžāĻĒ āĻ•āϰ⧇ āĻāĻ•āϟāĻŋ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āĻŸā§‡ āύāĻŋā§Ÿā§‡ āφāϏ⧇āĨ¤ āϤāĻžāχ āĻĢāϞāĻžāĻĢāϞ āĻšā§Ÿ `["L", "y", "d", "i", "a"]`āĨ¤

@@ -1356,11 +1362,11 @@ console.log(gen.next().value); #### āωāĻ¤ā§āϤāϰ: C -Regular functions cannot be stopped mid-way after invocation. However, a generator function can be "stopped" midway, and later continue from where it stopped. Every time a generator function encounters a `yield` keyword, the function yields the value specified after it. Note that the generator function in that case doesn’t _return_ the value, it _yields_ the value. +āϏāĻžāϧāĻžāϰāύ āĻĢāĻžāĻ‚āĻļāύāϕ⧇ āĻ•āϞ āĻ•āϰāĻžāϰ āĻĒāϰ āĻŽāĻžāĻāĻĒāĻĨ⧇ āĻĨāĻžāĻŽāĻŋā§Ÿā§‡ āĻĻā§‡ā§ŸāĻž āϝāĻžā§Ÿ āύāĻžāĨ¤ āĻ…āĻ¨ā§āϝāĻĻāĻŋāϕ⧇, āĻœā§‡āύāĻžāϰ⧇āϟāϰ āĻĢāĻžāĻ‚āĻļāύāϕ⧇ āĻŽāĻžāĻāĻĒāĻĨ⧇ āĻĨāĻžāĻŽāĻŋā§Ÿā§‡ āĻĻā§‡ā§ŸāĻž āϝāĻžā§Ÿ, āĻāĻŦāĻ‚ āϝ⧇āĻ–āĻžāύ⧇ āĻĨāĻžāĻŽāĻžāύ⧋ āĻšā§Ÿā§‡āĻ›āĻŋāϞ⧋ āϏ⧇āĻ–āĻžāύ āĻĨ⧇āϕ⧇āχ āĻĒ⧁āύāϰāĻžā§Ÿ āĻļ⧁āϰ⧁ āĻ•āϰāĻž āϝāĻžā§ŸāĨ¤ āĻœā§‡āύāĻžāϰ⧇āϟāϰ āĻĢāĻžāĻ‚āĻļāύ āĻĒā§āϰāϤāĻŋāĻŦāĻžāϰ āĻāĻ•āϟāĻŋ `yield` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄā§‡āϰ āĻŽā§āĻ–ā§‹āĻŽā§āĻ–āĻŋ āĻšāϝāĻŧ, āϤāĻ–āύ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āϤāĻžāϰ āĻĒāϰ⧇āϰ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻ•āϰāĻž āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻĒā§āϰāĻĻāĻžāύ āĻ•āϰ⧇āĨ¤ āĻŽāύ⧇ āϰāĻžāĻ–āĻŦ⧇āύ āϝ⧇ āϏ⧇āχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ āĻœā§‡āύāĻžāϰ⧇āϟāϰ āĻĢāĻžāĻ‚āĻļāύ āĻŽāĻžāύāϟāĻŋ _āϰāĻŋāϟāĻžāĻ°ā§āύ_ āĻ•āϰ⧇ āύāĻž, āĻāϟāĻŋ āĻŽāĻžāύāϟāĻŋāϕ⧇ _āχāĻ˛ā§āĻĄ_ āĻ•āϰ⧇ (āĻĢāϞāĻžāĻĢāϞ āĻĒā§āϰāĻĻāĻžāύ)āĨ¤ -First, we initialize the generator function with `i` equal to `10`. We invoke the generator function using the `next()` method. The first time we invoke the generator function, `i` is equal to `10`. It encounters the first `yield` keyword: it yields the value of `i`. The generator is now "paused", and `10` gets logged. +āĻĒā§āϰāĻĨāĻŽā§‡, āφāĻŽāϰāĻž āĻœā§‡āύāĻžāϰ⧇āϟāϰ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻļ⧁āϰ⧁ āĻ•āϰāĻŋ `i` āĻāϰ āϏāĻŽāĻžāύ `10` āĻĻāĻŋāϝāĻŧ⧇āĨ¤ āφāĻŽāϰāĻž `next()` āĻŽā§‡āĻĨāĻĄāϟāĻŋ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ āĻœā§‡āύāĻžāϰ⧇āϟāϰ āĻĢāĻžāĻ‚āĻļāύ āϚāĻžāϞ⧁ āĻ•āϰāĻŋāĨ¤ āĻĒā§āϰāĻĨāĻŽāĻŦāĻžāϰ āϝāĻ–āύ āφāĻŽāϰāĻž āĻœā§‡āύāĻžāϰ⧇āϟāϰ āĻĢāĻžāĻ‚āĻļāύ āϚāĻžāϞ⧁ āĻ•āϰāĻŋ, `i` āϏāĻŽāĻžāύ `10`āĨ¤ āĻāϟāĻŋ āĻĒā§āϰāĻĨāĻŽ `yield` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄā§‡āϰ āĻŽā§āĻ–ā§‹āĻŽā§āĻ–āĻŋ āĻšāϝāĻŧ: āĻāϟāĻŋ `i` āĻāϰ āĻŽāĻžāύ āĻĒā§āϰāĻĻāĻžāύ āĻ•āϰ⧇āĨ¤ āĻœā§‡āύāĻžāϰ⧇āϟāϰāϟāĻŋ āĻāĻ–āύ "paused" āĻ•āϰāĻž āĻšāϝāĻŧ⧇āϛ⧇ āĻāĻŦāĻ‚ `10` āϞāĻ— āĻšāϝāĻŧ⧇ āϗ⧇āϛ⧇āĨ¤ -Then, we invoke the function again with the `next()` method. It starts to continue where it stopped previously, still with `i` equal to `10`. Now, it encounters the next `yield` keyword, and yields `i * 2`. `i` is equal to `10`, so it returns `10 * 2`, which is `20`. This results in `10, 20`. +āϤāĻžāϰāĻĒāϰ, āφāĻŽāϰāĻž āφāĻŦāĻžāϰ `next()` āĻŽā§‡āĻĨāĻĄāϟāĻŋ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āϚāĻžāϞ⧁ āĻ•āϰāĻŋāĨ¤ āĻāĻ–āύāĻ“ `i` āĻāϰ āϏāĻŽāĻžāύ `10` āύāĻŋāϝāĻŧ⧇ āĻāϟāĻŋ āĻĒā§‚āĻ°ā§āĻŦ⧇ āϝ⧇āĻ–āĻžāύ⧇ āĻĨāĻžāĻŽā§‡ āϏ⧇āĻ–āĻžāύ āĻĨ⧇āϕ⧇āχ āϚāĻžāϞāĻŋāϝāĻŧ⧇ āϝ⧇āϤ⧇ āĻļ⧁āϰ⧁ āĻ•āϰ⧇āĨ¤ āĻāĻ–āύ, āĻāϟāĻŋ āĻĒāϰāĻŦāĻ°ā§āϤ⧀ `yield` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄā§‡āϰ āĻŽā§āĻ–ā§‹āĻŽā§āĻ–āĻŋ āĻšāϝāĻŧ āĻāĻŦāĻ‚ `i * 2` āĻĒāĻžā§ŸāĨ¤ `i` āĻšāϞ `10` āĻāϰ āϏāĻŽāĻžāύ, āϤāĻžāχ āĻāϟāĻŋ `10 * 2`, āϝāĻž āĻĒā§āϰāĻĻāĻžāύ āĻ•āϰ⧇ `20`āĨ¤ āĻāϰ āĻĢāϞ⧇ `10, 20` āĻĒāĻžāĻšā§āĻ›āĻŋāĨ¤

@@ -1371,11 +1377,11 @@ Then, we invoke the function again with the `next()` method. It starts to contin ```javascript const firstPromise = new Promise((res, rej) => { - setTimeout(res, 500, "one"); + setTimeout(res, 500, 'one'); }); const secondPromise = new Promise((res, rej) => { - setTimeout(res, 100, "two"); + setTimeout(res, 100, 'two'); }); Promise.race([firstPromise, secondPromise]).then((res) => console.log(res)); @@ -1401,7 +1407,7 @@ When we pass multiple promises to the `Promise.race` method, it resolves/rejects ###### 46. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -let person = { name: "Lydia" }; +let person = { name: 'Lydia' }; const members = [person]; person = null; @@ -1441,7 +1447,7 @@ We are only modifying the value of the `person` variable, and not the first elem ```javascript const person = { - name: "Lydia", + name: 'Lydia', age: 21, }; @@ -1470,7 +1476,7 @@ With a `for-in` loop, we can iterate through object keys, in this case `name` an ###### 48. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -console.log(3 + 4 + "5"); +console.log(3 + 4 + '5'); ``` - A: `"345"` @@ -1497,7 +1503,7 @@ Operator associativity is the order in which the compiler evaluates the expressi ###### 49. What's the value of `num`? ```javascript -const num = parseInt("7*6", 10); +const num = parseInt('7*6', 10); ``` - A: `42` @@ -1523,7 +1529,7 @@ Only the first number in the string is returned. Based on the _radix_ (the secon ```javascript [1, 2, 3].map((num) => { - if (typeof num === "number") return; + if (typeof num === 'number') return; return num * 2; }); ``` @@ -1551,12 +1557,12 @@ However, we don’t return a value. When we don’t return a value from the func ```javascript function getInfo(member, year) { - member.name = "Lydia"; - year = "1998"; + member.name = 'Lydia'; + year = '1998'; } -const person = { name: "Sarah" }; -const birthYear = "1997"; +const person = { name: 'Sarah' }; +const birthYear = '1997'; getInfo(person, birthYear); @@ -1588,15 +1594,15 @@ The value of `person` is an object. The argument `member` has a (copied) referen ```javascript function greeting() { - throw "Hello world!"; + throw 'Hello world!'; } function sayHi() { try { const data = greeting(); - console.log("It worked!", data); + console.log('It worked!', data); } catch (e) { - console.log("Oh no an error:", e); + console.log('Oh no an error:', e); } } @@ -1626,8 +1632,8 @@ With the `catch` statement, we can specify what to do if an exception is thrown ```javascript function Car() { - this.make = "Lamborghini"; - return { make: "Maserati" }; + this.make = 'Lamborghini'; + return { make: 'Maserati' }; } const myCar = new Car(); @@ -1705,7 +1711,7 @@ Dog.prototype.bark = function () { console.log(`Woof I am ${this.name}`); }; -const pet = new Dog("Mara"); +const pet = new Dog('Mara'); pet.bark(); @@ -1770,7 +1776,7 @@ export default counter; ```javascript // index.js -import myCounter from "./counter"; +import myCounter from './counter'; myCounter += 1; @@ -1799,7 +1805,7 @@ When we try to increment the value of `myCounter`, it throws an error: `myCounte ###### 58. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const name = "Lydia"; +const name = 'Lydia'; age = 21; console.log(delete name); @@ -1870,7 +1876,7 @@ This means that the value of `y` is equal to the first value in the array, which ###### 60. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const user = { name: "Lydia", age: 21 }; +const user = { name: 'Lydia', age: 21 }; const admin = { admin: true, ...user }; console.log(admin); @@ -1896,9 +1902,9 @@ It's possible to combine objects using the spread operator `...`. It lets you cr ###### 61. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const person = { name: "Lydia" }; +const person = { name: 'Lydia' }; -Object.defineProperty(person, "age", { value: 21 }); +Object.defineProperty(person, 'age', { value: 21 }); console.log(person); console.log(Object.keys(person)); @@ -1927,12 +1933,12 @@ Properties added using the `defineProperty` method are immutable by default. You ```javascript const settings = { - username: "lydiahallie", + username: 'lydiahallie', level: 19, health: 90, }; -const data = JSON.stringify(settings, ["level", "health"]); +const data = JSON.stringify(settings, ['level', 'health']); console.log(data); ``` @@ -2120,12 +2126,12 @@ The `Labrador` class receives two arguments, `name` since it extends `Dog`, and ```javascript // index.js -console.log("running index.js"); -import { sum } from "./sum.js"; +console.log('running index.js'); +import { sum } from './sum.js'; console.log(sum(1, 2)); // sum.js -console.log("running sum.js"); +console.log('running sum.js'); export const sum = (a, b) => a + b; ``` @@ -2153,7 +2159,7 @@ This is a difference between `require()` in CommonJS and `import`! With `require ```javascript console.log(Number(2) === Number(2)); console.log(Boolean(false) === Boolean(false)); -console.log(Symbol("foo") === Symbol("foo")); +console.log(Symbol('foo') === Symbol('foo')); ``` - A: `true`, `true`, `false` @@ -2176,7 +2182,7 @@ Every Symbol is entirely unique. The purpose of the argument passed to the Symbo ###### 69. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const name = "Lydia Hallie"; +const name = 'Lydia Hallie'; console.log(name.padStart(13)); console.log(name.padStart(2)); ``` @@ -2203,7 +2209,7 @@ If the argument passed to the `padStart` method is smaller than the length of th ###### 70. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -console.log("đŸĨ‘" + "đŸ’ģ"); +console.log('đŸĨ‘' + 'đŸ’ģ'); ``` - A: `"đŸĨ‘đŸ’ģ"` @@ -2227,11 +2233,11 @@ With the `+` operator, you can concatenate strings. In this case, we are concate ```javascript function* startGame() { - const āωāĻ¤ā§āϤāϰ = yield "Do you love JavaScript?"; - if (āωāĻ¤ā§āϤāϰ !== "Yes") { + const āωāĻ¤ā§āϤāϰ = yield 'Do you love JavaScript?'; + if (āωāĻ¤ā§āϤāϰ !== 'Yes') { return "Oh wow... Guess we're done here"; } - return "JavaScript loves you back â¤ī¸"; + return 'JavaScript loves you back â¤ī¸'; } const game = startGame(); @@ -2299,7 +2305,7 @@ In this case, the string is `Hello\nworld`, which gets logged. ```javascript async function getData() { - return await Promise.resolve("I made it!"); + return await Promise.resolve('I made it!'); } const data = getData(); @@ -2336,7 +2342,7 @@ function addToList(item, list) { return list.push(item); } -const result = addToList("apple", ["banana"]); +const result = addToList('apple', ['banana']); console.log(result); ``` @@ -2396,7 +2402,7 @@ Since `shape` is frozen, and since the value of `x` is not an object, we cannot ###### 76. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const { firstName: myName } = { firstName: "Lydia" }; +const { firstName: myName } = { firstName: 'Lydia' }; console.log(firstName); ``` @@ -2414,7 +2420,7 @@ console.log(firstName); By using [destructuring assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) syntax we can unpack values from arrays, or properties from objects, into distinct variables: ```javascript -const { firstName } = { firstName: "Lydia" }; +const { firstName } = { firstName: 'Lydia' }; // ES5 version: // var firstName = { firstName: 'Lydia' }.firstName; @@ -2424,7 +2430,7 @@ console.log(firstName); // "Lydia" Also, a property can be unpacked from an object and assigned to a variable with a different name than the object property: ```javascript -const { firstName: myName } = { firstName: "Lydia" }; +const { firstName: myName } = { firstName: 'Lydia' }; // ES5 version: // var myName = { firstName: 'Lydia' }.firstName; @@ -2437,7 +2443,7 @@ Therefore, `firstName` does not exist as a variable, thus attempting to access i **Note:** Be aware of the `global scope` properties: ```javascript -const { name: myName } = { name: "Lydia" }; +const { name: myName } = { name: 'Lydia' }; console.log(myName); // "lydia" console.log(name); // "" ----- Browser e.g. Chrome @@ -2530,7 +2536,7 @@ The third time, we pass `5 * 2` to the function which gets evaluated to `10`. Th ###### 79. What is the output? ```javascript -const myLifeSummedUp = ["☕", "đŸ’ģ", "🍷", "đŸĢ"]; +const myLifeSummedUp = ['☕', 'đŸ’ģ', '🍷', 'đŸĢ']; for (let item in myLifeSummedUp) { console.log(item); @@ -2626,13 +2632,13 @@ In this case, if we didn't pass a value or if we passed `undefined`, `name` woul ###### 82. What is the output? ```javascript -var status = "😎"; +var status = '😎'; setTimeout(() => { - const status = "😍"; + const status = '😍'; const data = { - status: "đŸĨ‘", + status: 'đŸĨ‘', getStatus() { return this.status; }, @@ -2666,12 +2672,12 @@ With the `call` method, we can change the object to which the `this` keyword ref ```javascript const person = { - name: "Lydia", + name: 'Lydia', age: 21, }; let city = person.city; -city = "Amsterdam"; +city = 'Amsterdam'; console.log(person); ``` @@ -2735,7 +2741,7 @@ Variables with the `const` and `let` keywords are _block-scoped_. A block is any ###### 85. What kind of information would get logged? ```javascript -fetch("https://www.website.com/api/user/1") +fetch('https://www.website.com/api/user/1') .then((res) => res.json()) .then((res) => console.log(res)); ``` @@ -2791,7 +2797,7 @@ By setting `hasName` equal to `name`, you set `hasName` equal to whatever value ###### 87. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -console.log("I want pizza"[0]); +console.log('I want pizza'[0]); ``` - A: `"""` @@ -2846,11 +2852,11 @@ If you're trying to set a default parameter's value equal to a parameter that is ```javascript // module.js -export default () => "Hello world"; -export const name = "Lydia"; +export default () => 'Hello world'; +export const name = 'Lydia'; // index.js -import * as data from "./module"; +import * as data from './module'; console.log(data); ``` @@ -2883,7 +2889,7 @@ class Person { } } -const member = new Person("John"); +const member = new Person('John'); console.log(typeof member); ``` @@ -2943,7 +2949,7 @@ Then, we try to use the `.push` method on `newList`. Since `newList` is the nume ```javascript function giveLydiaPizza() { - return "Here is pizza!"; + return 'Here is pizza!'; } const giveLydiaChocolate = () => @@ -2974,7 +2980,7 @@ Regular functions, such as the `giveLydiaPizza` function, have a `prototype` pro ```javascript const person = { - name: "Lydia", + name: 'Lydia', age: 21, }; @@ -3034,7 +3040,7 @@ function getItems(fruitList, favoriteFruit, ...args) { return [...fruitList, ...args, favoriteFruit]; } -getItems(["banana", "apple"], "pear", "orange"); +getItems(['banana', 'apple'], 'pear', 'orange'); ``` The above example works. This returns the array `[ 'banana', 'apple', 'orange', 'pear' ]` @@ -3048,8 +3054,8 @@ The above example works. This returns the array `[ 'banana', 'apple', 'orange', ```javascript function nums(a, b) { - if (a > b) console.log("a is bigger"); - else console.log("b is bigger"); + if (a > b) console.log('a is bigger'); + else console.log('b is bigger'); return; a + b; } @@ -3089,13 +3095,13 @@ This means that `a + b` is never reached, since a function stops running after t ```javascript class Person { constructor() { - this.name = "Lydia"; + this.name = 'Lydia'; } } Person = class AnotherPerson { constructor() { - this.name = "Sarah"; + this.name = 'Sarah'; } }; @@ -3124,7 +3130,7 @@ We can set classes equal to other classes/function constructors. In this case, w ```javascript const info = { - [Symbol("a")]: "b", + [Symbol('a')]: 'b', }; console.log(info); @@ -3193,7 +3199,7 @@ The following function would have returned an object: ###### 99. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const name = "Lydia"; +const name = 'Lydia'; console.log(name()); ``` @@ -3225,8 +3231,8 @@ ReferenceErrors get thrown when JavaScript isn't able to find a reference to a v ```javascript // 🎉✨ This is my 100th question! ✨🎉 -const output = `${[] && "Im"}possible! -You should${"" && `n't`} see a therapist after so much JavaScript lol`; +const output = `${[] && 'Im'}possible! +You should${'' && `n't`} see a therapist after so much JavaScript lol`; ``` - A: `possible! You should see a therapist after so much JavaScript lol` @@ -3252,7 +3258,7 @@ You should${"" && `n't`} see a therapist after so much JavaScript lol`; ```javascript const one = false || {} || null; -const two = null || false || ""; +const two = null || false || ''; const three = [] || 0 || true; console.log(one, two, three); @@ -3284,16 +3290,16 @@ With the `||` operator, we can return the first truthy operand. If all values ar ###### 102. What's the value of output? ```javascript -const myPromise = () => Promise.resolve("I have resolved!"); +const myPromise = () => Promise.resolve('I have resolved!'); function firstFunction() { myPromise().then((res) => console.log(res)); - console.log("second"); + console.log('second'); } async function secondFunction() { console.log(await myPromise()); - console.log("second"); + console.log('second'); } firstFunction(); @@ -3331,8 +3337,8 @@ This means that it waited for the `myPromise` to resolve with the value `I have const set = new Set(); set.add(1); -set.add("Lydia"); -set.add({ name: "Lydia" }); +set.add('Lydia'); +set.add({ name: 'Lydia' }); for (let item of set) { console.log(item + 2); @@ -3392,13 +3398,13 @@ In this case, we just passed the numerical value `5`. It returns a resolved prom ```javascript function compareMembers(person1, person2 = person) { if (person1 !== person2) { - console.log("Not the same!"); + console.log('Not the same!'); } else { - console.log("They are the same!"); + console.log('They are the same!'); } } -const person = { name: "Lydia" }; +const person = { name: 'Lydia' }; compareMembers(person); ``` @@ -3437,7 +3443,7 @@ const colorConfig = { yellow: false, }; -const colors = ["pink", "red", "blue"]; +const colors = ['pink', 'red', 'blue']; console.log(colorConfig.colors[1]); ``` @@ -3466,7 +3472,7 @@ JavaScript interprets (or unboxes) statements. When we use bracket notation, it ###### 107. What's its value? ```javascript -console.log("â¤ī¸" === "â¤ī¸"); +console.log('â¤ī¸' === 'â¤ī¸'); ``` - A: `true` @@ -3487,14 +3493,14 @@ Under the hood, emojis are unicodes. The unicodes for the heart emoji is `"U+276 ###### 108. Which of these methods modifies the original array? ```javascript -const emojis = ["✨", "đŸĨ‘", "😍"]; +const emojis = ['✨', 'đŸĨ‘', '😍']; -emojis.map((x) => x + "✨"); -emojis.filter((x) => x !== "đŸĨ‘"); -emojis.find((x) => x !== "đŸĨ‘"); -emojis.reduce((acc, cur) => acc + "✨"); -emojis.slice(1, 2, "✨"); -emojis.splice(1, 2, "✨"); +emojis.map((x) => x + '✨'); +emojis.filter((x) => x !== 'đŸĨ‘'); +emojis.find((x) => x !== 'đŸĨ‘'); +emojis.reduce((acc, cur) => acc + '✨'); +emojis.slice(1, 2, '✨'); +emojis.splice(1, 2, '✨'); ``` - A: `All of them` @@ -3519,10 +3525,10 @@ With `splice` method, we modify the original array by deleting, replacing or add ###### 109. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const food = ["🍕", "đŸĢ", "đŸĨ‘", "🍔"]; +const food = ['🍕', 'đŸĢ', 'đŸĨ‘', '🍔']; const info = { favoriteFood: food[0] }; -info.favoriteFood = "🍝"; +info.favoriteFood = '🍝'; console.log(food); ``` @@ -3576,7 +3582,7 @@ const jsonArray = JSON.stringify([1, 2, 3]); // '[1, 2, 3]' JSON.parse(jsonArray); // [1, 2, 3] // Stringifying an object into valid JSON, then parsing the JSON string to a JavaScript value: -const jsonArray = JSON.stringify({ name: "Lydia" }); // '{"name":"Lydia"}' +const jsonArray = JSON.stringify({ name: 'Lydia' }); // '{"name":"Lydia"}' JSON.parse(jsonArray); // { name: 'Lydia' } ``` @@ -3588,11 +3594,11 @@ JSON.parse(jsonArray); // { name: 'Lydia' } ###### 111. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -let name = "Lydia"; +let name = 'Lydia'; function getName() { console.log(name); - let name = "Sarah"; + let name = 'Sarah'; } getName(); @@ -3615,7 +3621,7 @@ Variables with the `let` keyword (and `const`) are hoisted, but unlike `var`, do If we wouldn't have declared the `name` variable within the `getName` function, the javascript engine would've looked down the _scope chain_. The outer scope has a variable called `name` with the value of `Lydia`. In that case, it would've logged `Lydia`. ```javascript -let name = "Lydia"; +let name = 'Lydia'; function getName() { console.log(name); @@ -3633,11 +3639,11 @@ getName(); // Lydia ```javascript function* generatorOne() { - yield ["a", "b", "c"]; + yield ['a', 'b', 'c']; } function* generatorTwo() { - yield* ["a", "b", "c"]; + yield* ['a', 'b', 'c']; } const one = generatorOne(); @@ -3683,7 +3689,7 @@ console.log(two.next().value); // undefined ###### 113. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -console.log(`${((x) => x)("I love")} to program`); +console.log(`${((x) => x)('I love')} to program`); ``` - A: `I love to program` @@ -3708,7 +3714,7 @@ Expressions within template literals are evaluated first. This means that the st ```javascript let config = { alert: setInterval(() => { - console.log("Alert!"); + console.log('Alert!'); }, 1000), }; @@ -3740,16 +3746,16 @@ Since it was not cleared, the `setInterval` callback function will still get inv ```javascript const myMap = new Map(); -const myFunc = () => "greeting"; +const myFunc = () => 'greeting'; -myMap.set(myFunc, "Hello world!"); +myMap.set(myFunc, 'Hello world!'); //1 -myMap.get("greeting"); +myMap.get('greeting'); //2 myMap.get(myFunc); //3 -myMap.get(() => "greeting"); +myMap.get(() => 'greeting'); ``` - A: 1 @@ -3776,14 +3782,14 @@ When adding a key/value pair using the `set` method, the key will be the value o ```javascript const person = { - name: "Lydia", + name: 'Lydia', age: 21, }; const changeAge = (x = { ...person }) => (x.age += 1); const changeAgeAndName = (x = { ...person }) => { x.age += 1; - x.name = "Sarah"; + x.name = 'Sarah'; }; changeAge(person); @@ -3842,7 +3848,7 @@ With the spread operator `...`, we can _spread_ iterables to individual elements ```javascript let num = 1; -const list = ["đŸĨŗ", "🤠", "đŸĨ°", "đŸ¤Ē"]; +const list = ['đŸĨŗ', '🤠', 'đŸĨ°', 'đŸ¤Ē']; console.log(list[(num += 1)]); ``` @@ -3868,11 +3874,11 @@ With the `+=` operator, we're incrementing the value of `num` by `1`. `num` had ```javascript const person = { - firstName: "Lydia", - lastName: "Hallie", + firstName: 'Lydia', + lastName: 'Hallie', pet: { - name: "Mara", - breed: "Dutch Tulip Hound", + name: 'Mara', + breed: 'Dutch Tulip Hound', }, getFullName() { return `${this.firstName} ${this.lastName}`; @@ -3910,10 +3916,10 @@ With the optional chaining operator `?.`, we no longer have to explicitly check ###### 120. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const groceries = ["banana", "apple", "peanuts"]; +const groceries = ['banana', 'apple', 'peanuts']; -if (groceries.indexOf("banana")) { - console.log("We have to buy bananas!"); +if (groceries.indexOf('banana')) { + console.log('We have to buy bananas!'); } else { console.log(`We don't have to buy bananas!`); } @@ -3969,10 +3975,10 @@ The `language` method is a `setter`. Setters don't hold an actual value, their p ###### 122. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const name = "Lydia Hallie"; +const name = 'Lydia Hallie'; -console.log(!typeof name === "object"); -console.log(!typeof name === "string"); +console.log(!typeof name === 'object'); +console.log(!typeof name === 'string'); ``` - A: `false` `true` @@ -4087,14 +4093,14 @@ myFunc(1, 2, 3); ```javascript function getFine(speed, amount) { - const formattedSpeed = new Intl.NumberFormat("en-US", { - style: "unit", - unit: "mile-per-hour", + const formattedSpeed = new Intl.NumberFormat('en-US', { + style: 'unit', + unit: 'mile-per-hour', }).format(speed); - const formattedAmount = new Intl.NumberFormat("en-US", { - style: "currency", - currency: "USD", + const formattedAmount = new Intl.NumberFormat('en-US', { + style: 'currency', + currency: 'USD', }).format(amount); return `The driver drove ${formattedSpeed} and has to pay ${formattedAmount}`; @@ -4123,8 +4129,8 @@ With the `Intl.NumberFormat` method, we can format numeric values to any locale. ###### 127. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const spookyItems = ["đŸ‘ģ", "🎃", "🕸"]; -({ item: spookyItems[3] } = { item: "💀" }); +const spookyItems = ['đŸ‘ģ', '🎃', '🕸']; +({ item: spookyItems[3] } = { item: '💀' }); console.log(spookyItems); ``` @@ -4149,7 +4155,7 @@ By destructuring objects, we can unpack values from the right-hand object, and a ###### 128. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const name = "Lydia Hallie"; +const name = 'Lydia Hallie'; const age = 21; console.log(Number.isNaN(name)); @@ -4185,7 +4191,7 @@ const randomValue = 21; function getInfo() { console.log(typeof randomValue); - const randomValue = "Lydia Hallie"; + const randomValue = 'Lydia Hallie'; } getInfo(); @@ -4211,7 +4217,7 @@ Variables declared with the `const` keyword are not referenceable before their i ###### 130. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const myPromise = Promise.resolve("Woah some cool data"); +const myPromise = Promise.resolve('Woah some cool data'); (async () => { try { @@ -4219,7 +4225,7 @@ const myPromise = Promise.resolve("Woah some cool data"); } catch { throw new Error(`Oops didn't work`); } finally { - console.log("Oh finally!"); + console.log('Oh finally!'); } })(); ``` @@ -4244,7 +4250,7 @@ In the `try` block, we're logging the awaited value of the `myPromise` variable: ###### 131. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const emojis = ["đŸĨ‘", ["✨", "✨", ["🍕", "🍕"]]]; +const emojis = ['đŸĨ‘', ['✨', '✨', ['🍕', '🍕']]]; console.log(emojis.flat(1)); ``` @@ -4317,19 +4323,19 @@ We invoke `counterTwo.increment()`, which sets `count` to `3`. Then, we log the ###### 133. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const myPromise = Promise.resolve(Promise.resolve("Promise")); +const myPromise = Promise.resolve(Promise.resolve('Promise')); function funcOne() { - setTimeout(() => console.log("Timeout 1!"), 0); + setTimeout(() => console.log('Timeout 1!'), 0); myPromise.then((res) => res).then((res) => console.log(`${res} 1!`)); - console.log("Last line 1!"); + console.log('Last line 1!'); } async function funcTwo() { const res = await myPromise; console.log(`${res} 2!`); - setTimeout(() => console.log("Timeout 2!"), 0); - console.log("Last line 2!"); + setTimeout(() => console.log('Timeout 2!'), 0); + console.log('Last line 2!'); } funcOne(); @@ -4374,7 +4380,7 @@ export default function sum(x) { } // index.js -import * as sum from "./sum"; +import * as sum from './sum'; ``` - A: `sum(4)` @@ -4391,12 +4397,12 @@ With the asterisk `*`, we import all exported values from that file, both defaul ```javascript // info.js -export const name = "Lydia"; +export const name = 'Lydia'; export const age = 21; -export default "I love JavaScript"; +export default 'I love JavaScript'; // index.js -import * as info from "./info"; +import * as info from './info'; console.log(info); ``` @@ -4427,13 +4433,13 @@ We can invoke this function, by calling `sum.default` ```javascript const handler = { - set: () => console.log("Added a new property!"), - get: () => console.log("Accessed a property!"), + set: () => console.log('Added a new property!'), + get: () => console.log('Accessed a property!'), }; const person = new Proxy({}, handler); -person.name = "Lydia"; +person.name = 'Lydia'; person.name; ``` @@ -4463,7 +4469,7 @@ Then, we access a property value on the proxy object, and the `get` property on ###### 136. Which of the following will modify the `person` object? ```javascript -const person = { name: "Lydia Hallie" }; +const person = { name: 'Lydia Hallie' }; Object.seal(person); ``` @@ -4491,9 +4497,9 @@ However, you can still modify the value of existing properties. ```javascript const person = { - name: "Lydia Hallie", + name: 'Lydia Hallie', address: { - street: "100 Main St", + street: '100 Main St', }, }; @@ -4593,8 +4599,8 @@ In ES2020, we can add private variables in classes by using the `#`. We cannot a ```javascript const teams = [ - { name: "Team 1", members: ["Paul", "Lisa"] }, - { name: "Team 2", members: ["Laura", "Tim"] }, + { name: 'Team 1', members: ['Paul', 'Lisa'] }, + { name: 'Team 2', members: ['Laura', 'Tim'] }, ]; function* getMembers(members) { @@ -4637,8 +4643,8 @@ If we would've written `yield`, `return yield`, or `return`, the entire generato ```javascript const person = { - name: "Lydia Hallie", - hobbies: ["coding"], + name: 'Lydia Hallie', + hobbies: ['coding'], }; function addHobby(hobby, hobbies = person.hobbies) { @@ -4646,9 +4652,9 @@ function addHobby(hobby, hobbies = person.hobbies) { return hobbies; } -addHobby("running", []); -addHobby("dancing"); -addHobby("baking", person.hobbies); +addHobby('running', []); +addHobby('dancing'); +addHobby('baking', person.hobbies); console.log(person.hobbies); ``` @@ -4717,11 +4723,11 @@ We create the variable `pet` which is an instance of the `Flamingo` class. When ###### 143. Which of the options result(s) in an error? ```javascript -const emojis = ["🎄", "🎅đŸŧ", "🎁", "⭐"]; +const emojis = ['🎄', '🎅đŸŧ', '🎁', '⭐']; -/* 1 */ emojis.push("đŸĻŒ"); +/* 1 */ emojis.push('đŸĻŒ'); /* 2 */ emojis.splice(0, 2); -/* 3 */ emojis = [...emojis, "đŸĨ‚"]; +/* 3 */ emojis = [...emojis, 'đŸĨ‚']; /* 4 */ emojis.length = 0; ``` @@ -4807,9 +4813,9 @@ function getFruit(fruits) { console.log(fruits?.[1]?.[1]); } -getFruit([["🍊", "🍌"], ["🍍"]]); +getFruit([['🍊', '🍌'], ['🍍']]); getFruit(); -getFruit([["🍍"], ["🍊", "🍌"]]); +getFruit([['🍍'], ['🍊', '🍌']]); ``` - A: `null`, `undefined`, 🍌 @@ -4875,8 +4881,8 @@ We set the variable `calc` equal to a new instance of the `Calc` class. Then, we ```javascript const user = { - email: "e@mail.com", - password: "12345", + email: 'e@mail.com', + password: '12345', }; const updateUser = ({ email, password }) => { @@ -4891,7 +4897,7 @@ const updateUser = ({ email, password }) => { return user; }; -const updatedUser = updateUser({ email: "new@email.com" }); +const updatedUser = updateUser({ email: 'new@email.com' }); console.log(updatedUser === user); ``` @@ -4916,11 +4922,11 @@ The `updateUser` function updates the values of the `email` and `password` prope ###### 149. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const fruit = ["🍌", "🍊", "🍎"]; +const fruit = ['🍌', '🍊', '🍎']; fruit.slice(0, 1); fruit.splice(0, 1); -fruit.unshift("🍇"); +fruit.unshift('🍇'); console.log(fruit); ``` @@ -4948,11 +4954,11 @@ At last, we invoke the `unshift` method on the `fruit` array, which modifies the ```javascript const animals = {}; -let dog = { emoji: "đŸļ" }; -let cat = { emoji: "🐈" }; +let dog = { emoji: 'đŸļ' }; +let cat = { emoji: '🐈' }; -animals[dog] = { ...dog, name: "Mara" }; -animals[cat] = { ...cat, name: "Sara" }; +animals[dog] = { ...dog, name: 'Mara' }; +animals[cat] = { ...cat, name: 'Sara' }; console.log(animals[dog]); ``` @@ -4984,13 +4990,13 @@ Logging `animals[dog]`, or actually `animals["[object Object]"]` since convertin ```javascript const user = { - email: "my@email.com", + email: 'my@email.com', updateEmail: (email) => { this.email = email; }, }; -user.updateEmail("new@email.com"); +user.updateEmail('new@email.com'); console.log(user.email); ``` @@ -5014,10 +5020,10 @@ The `updateEmail` function is an arrow function, and is not bound to the `user` ###### 152. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const promise1 = Promise.resolve("First"); -const promise2 = Promise.resolve("Second"); -const promise3 = Promise.reject("Third"); -const promise4 = Promise.resolve("Fourth"); +const promise1 = Promise.resolve('First'); +const promise2 = Promise.resolve('Second'); +const promise3 = Promise.reject('Third'); +const promise4 = Promise.resolve('Fourth'); const runPromises = async () => { const res1 = await Promise.all([promise1, promise2]); @@ -5050,8 +5056,8 @@ The `Promise.all` method runs the passed promises in parallel. If one promise fa ###### 153. What should the value of `method` be to log `{ name: "Lydia", age: 22 }`? ```javascript -const keys = ["name", "age"]; -const values = ["Lydia", 22]; +const keys = ['name', 'age']; +const values = ['Lydia', 22]; const method = /* ?? */ @@ -5086,7 +5092,7 @@ This creates an array of subarrays containing the correct keys and values, which ```javascript const createMember = ({ email, address = {} }) => { const validEmail = /.+\@.+\..+/.test(email); - if (!validEmail) throw new Error("Valid email pls"); + if (!validEmail) throw new Error('Valid email pls'); return { email, @@ -5094,7 +5100,7 @@ const createMember = ({ email, address = {} }) => { }; }; -const member = createMember({ email: "my@email.com" }); +const member = createMember({ email: 'my@email.com' }); console.log(member); ``` @@ -5118,10 +5124,10 @@ The default value of `address` is an empty object `{}`. When we set the variable ###### 155. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -let randomValue = { name: "Lydia" }; +let randomValue = { name: 'Lydia' }; randomValue = 23; -if (!typeof randomValue === "string") { +if (!typeof randomValue === 'string') { console.log("It's not a string!"); } else { console.log("Yay it's a string!"); From 70d1278b545d1218964b3e6555947f91d366dc5a Mon Sep 17 00:00:00 2001 From: iamsaief Date: Thu, 23 May 2024 04:09:10 +0600 Subject: [PATCH 03/12] added translation till 50 --- bn-BD/README_bn-BD.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/bn-BD/README_bn-BD.md b/bn-BD/README_bn-BD.md index d9a00cf2..6eb10aab 100644 --- a/bn-BD/README_bn-BD.md +++ b/bn-BD/README_bn-BD.md @@ -1397,7 +1397,7 @@ Promise.race([firstPromise, secondPromise]).then((res) => console.log(res)); #### āωāĻ¤ā§āϤāϰ: B -When we pass multiple promises to the `Promise.race` method, it resolves/rejects the _first_ promise that resolves/rejects. To the `setTimeout` method, we pass a timer: 500ms for the first promise (`firstPromise`), and 100ms for the second promise (`secondPromise`). This means that the `secondPromise` resolves first with the value of `'two'`. `res` now holds the value of `'two'`, which gets logged. +āϝāĻ–āύ `Promise.race` āĻŽā§‡āĻĨāĻĄā§‡ āφāĻŽāϰāĻž āĻāĻ•āĻžāϧāĻŋāĻ• āĻĒā§āϰ⧋āĻŽāĻŋāϏ āĻĒāĻžāϏ āĻ•āϰāĻŋ, _ā§§āĻŽ_ āϝ⧇ āĻĒā§āϰāĻŽāĻŋāϏāϟāĻŋ āϰāĻŋāϏāϞāĻ­/āϰāĻŋāĻœā§‡āĻ•ā§āϟ āĻšā§Ÿ āϤāĻžāϕ⧇āχ āĻāϟāĻž āϰāĻŋāϏāϞāĻ­/āϰāĻŋāĻœā§‡āĻ•ā§āϟ āĻ•āϰ⧇āĨ¤ `setTimeout` āĻŽā§‡āĻĨāĻĄā§‡ āφāĻŽāϰāĻž āĻāĻ•āϟāĻŋ āϟāĻžāχāĻŽāĻžāϰ āĻĒāĻžāϏ āĻ•āϰ⧇āĻ›āĻŋāσ ā§§āĻŽ āĻĒā§āϰāĻŽāĻŋāϏ⧇ (`firstPromise`) 500ms āĻāĻŦāĻ‚ ⧍⧟ āĻĒā§āϰāĻŽāĻŋāϏ⧇ (`secondPromise`) 100msāĨ¤ āĻāϰ āĻŽāĻžāύ⧇ āĻšāϞ, `secondPromise`āϟāĻŋ `'two'` āĻ­ā§āϝāĻžāϞ⧁ āύāĻŋā§Ÿā§‡ āĻĒā§āϰāĻĨāĻŽā§‡ āϰāĻŋāϜāϞāĻ­ āĻšā§ŸāĨ¤ āϤāĻžāχ `res` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋāχ (`'two'`) āϞāĻ— āĻšāĻšā§āϛ⧇āĨ¤

@@ -1424,19 +1424,19 @@ console.log(members); #### āωāĻ¤ā§āϤāϰ: D -First, we declare a variable `person` with the value of an object that has a `name` property. +ā§§āĻŽā§‡, āφāĻŽāϰāĻž āĻāĻ•āϟāĻŋ āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞ `person` āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰ⧇āĻ›āĻŋ, āĻāϟāĻŋ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āϝāĻžāϰ āĻāĻ•āϟāĻŋ `name` āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ (āĻ•āĻŋ) āφāϛ⧇āĨ¤ -Then, we declare a variable called `members`. We set the first element of that array equal to the value of the `person` variable. Objects interact by _reference_ when setting them equal to each other. When you assign a reference from one variable to another, you make a _copy_ of that reference. (note that they don't have the _same_ reference!) +āϤāĻžāϰāĻĒāϰ āφāĻŽāϰāĻž āφāϰāĻ“ āĻāĻ•āϟāĻŋ āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰ⧇āĻ›āĻŋ `members` āύāĻžāĻŽā§‡āĨ¤ āĻāϟāĻŋ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇ āϝāĻžāϰ ā§§āĻŽ āχāύāĻĄā§‡āĻ•ā§āϏāϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁ āϏāĻŽāĻžāύ āĻšāĻšā§āϛ⧇ `person` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āϞāĻŦāϟāĻŋāĨ¤ āϝāĻ–āύ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āĻāϕ⧇ āĻ“āĻĒāϰ⧇āϰ āϏāĻŽāĻžāύ āϏ⧇āϟ āĻ•āϰāĻž āĻšā§Ÿ āĻāϰāĻž _āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ_ āĻāϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡ āĻ•āĻžāϜ āĻ•āϰ⧇āĨ¤ āϝāĻ–āύ āφāĻĒāύāĻŋ āĻāĻ•āϟāĻŋ āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞāϕ⧇ āĻ…ā§āϝāĻžāϏāĻžāχāύ āĻ•āϰāϛ⧇āύ āĻ…āĻ¨ā§āϝ āĻ­ā§āϝāϰāĻŋā§Ÿā§‡āĻŦāϞ⧇āϰ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ, āφāĻĒāύāĻŋ āφāϏāϞ⧇ āϐ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ⧇āϰ āĻāĻ•āϟāĻŋ _āĻ•āĻĒāĻŋ_ āĻ•āϰāϛ⧇āύāĨ¤ _āĻŽāύ⧇ āϰāĻžāĻ–āĻŦ⧇āύ āϤāĻžāĻĻ⧇āϰ āĻ•āĻžāϛ⧇ āĻ•āĻŋāĻ¨ā§āϤ⧁ āĻāĻ•āχ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āύ⧇āχ_ ! -Then, we set the variable `person` equal to `null`. +āĻĒāϰāĻŦāĻ°ā§āϤāĻŋāϤ⧇ `person` āĻ­ā§āϝāĻžā§Ÿā§‡āĻŦāϞāϕ⧇ āφāĻŽāϰāĻž āϏ⧇āϟ āĻ•āϰāĻ›āĻŋ āϏāĻŽāĻžāύ āϏāĻŽāĻžāύ `null`āĨ¤ -We are only modifying the value of the `person` variable, and not the first element in the array, since that element has a different (copied) reference to the object. The first element in `members` still holds its reference to the original object. When we log the `members` array, the first element still holds the value of the object, which gets logged. +āφāĻŽāϰāĻž āϕ⧇āĻŦāϞ `person` āĻ­ā§āϝāĻžā§Ÿā§‡āĻŦāϞāϕ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇āĻ›āĻŋ, āĻ…ā§āϝāĻžāϰ⧇āϰ ā§§āĻŽ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟāϕ⧇ āύ⧟, āϝ⧇āĻšā§‡āϤ⧁ āϐ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟāĻŋāϰ āĻ•āĻžāϛ⧇ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻ­āĻŋāĻ¨ā§āύ (āĻ•āĻĒāĻŋāĻ•ā§ƒāϤ) āĻāĻ•āϟāĻŋ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āφāϛ⧇āĨ¤ `members` āĻ…ā§āϝāĻžāϰ⧇āϰ ā§§āĻŽ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟāϟāĻŋ āĻāĻ–āύ⧋ āφāϏāϞ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāĻŋāϰ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏāϟāĻŋ āϧāϰ⧇ āϰ⧇āϖ⧇āϛ⧇ āϤāĻžāχ ā§§āĻŽ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟāϟāĻŋ āϤāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁āĻ“ āϧāϰ⧇ āϰ⧇āϖ⧇āϛ⧇ āφāϏāϞ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇āχāĨ¤ āĻĢāϞ⧇ āϝāĻ–āύ `members` āĻ…ā§āϝāĻžāϰ⧇āϕ⧇ āϞāĻ— āĻ•āϰāĻž āĻšā§Ÿ āϏ⧇āϟāĻžāχ āϞāĻ— āĻšā§Ÿā§‡āϛ⧇āĨ¤

@@ -1466,7 +1466,7 @@ for (const item in person) { #### āωāĻ¤ā§āϤāϰ: B -With a `for-in` loop, we can iterate through object keys, in this case `name` and `age`. Under the hood, object keys are strings (if they're not a Symbol). On every loop, we set the value of `item` equal to the current key it’s iterating over. First, `item` is equal to `name`, and gets logged. Then, `item` is equal to `age`, which gets logged. +`for-in` āϞ⧁āĻĒ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ āφāĻŽāϰāĻž āϕ⧇āĻŦāϞ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻ•āĻŋ-āϗ⧁āϞāĻŋāϰ āĻŽāĻ§ā§āϝ⧇āχ āĻĒ⧁āύāϰāĻžāĻŦ⧃āĻ¤ā§āϤāĻŋ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ, āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ `name` āĻ“ `age`āĨ¤ āϭ⧇āϤāϰ⧇ āϭ⧇āϤāϰ⧇ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āϕ⧀āϗ⧁āϞāĻŋ āĻšāϞ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ (āϝāĻĻāĻŋ āϤāĻžāϰāĻž āϕ⧋āύ āĻāĻ•āϟāĻŋ āĻĒā§āϰāϤ⧀āĻ• (Symbol) āύāĻž āĻšāϝāĻŧ)āĨ¤ āĻĒā§āϰāϤāĻŋāϟāĻŋ āϞ⧁āĻĒ⧇, āφāĻŽāϰāĻž `item` āĻŽāĻžāύāϟāĻŋ āĻŦāĻ°ā§āϤāĻŽāĻžāύ āϕ⧀-āϟāĻŋāϰ āϏāĻŽāĻžāύ āϏ⧇āϟ āĻ•āϰāĻŋ āϝāĻžāϰ āĻĒ⧁āύāϰāĻžāĻŦ⧃āĻ¤ā§āϤāĻŋ āĻšāĻšā§āϛ⧇āĨ¤ ā§§āĻŽā§‡, `item`-āϟāĻŋ `name`-āĻāϰ āϏāĻŽāĻžāύ, āĻāĻŦāĻ‚ āϞāĻ— āĻ•āϰāĻž āĻšāϝāĻŧāĨ¤ āϤāĻžāϰāĻĒāϰ, `item`-āϟāĻŋ `age`-āĻāϰ āϏāĻŽāĻžāύ, āϝāĻž āϞāĻ— āĻšāϝāĻŧāĨ¤

@@ -1489,18 +1489,18 @@ console.log(3 + 4 + '5'); #### āωāĻ¤ā§āϤāϰ: B -Operator associativity is the order in which the compiler evaluates the expressions, either left-to-right or right-to-left. This only happens if all operators have the _same_ precedence. We only have one type of operator: `+`. For addition, the associativity is left-to-right. +**āĻ…āĻĒāĻžāϰ⧇āϟāϰ āĻ…ā§āϝāĻžāϏ⧋āϏāĻŋāϝāĻŧ⧇āϟāĻŋāĻ­āĻŋāϟāĻŋ** āĻšāϞ āϏ⧇āχ āĻ•ā§āϰāĻŽ āϝ⧇āĻ–āĻžāύ⧇ āĻ•āĻŽā§āĻĒāĻžāχāϞāĻžāϰ āĻŦāĻžāĻŽ-āĻĨ⧇āϕ⧇-āĻĄāĻžāύ āĻŦāĻž āĻĄāĻžāύ-āĻĨ⧇āϕ⧇-āĻŦāĻžāĻŽā§‡ āĻāĻ•ā§āϏāĻĒā§āϰ⧇āĻļāύāϕ⧇ āĻŽā§‚āĻ˛ā§āϝāĻžāϝāĻŧāύ āĻ•āϰ⧇āĨ¤ āĻāϟāĻŋ āĻļ⧁āϧ⧁āĻŽāĻžāĻ¤ā§āϰ āϤāĻ–āύāχ āϘāĻŸā§‡ āϝāĻ–āύ āϏāĻŽāĻ¸ā§āϤ āĻ…āĻĒāĻžāϰ⧇āϟāϰ⧇āϰ _āĻāĻ•āχ_ āĻ…āĻ—ā§āϰāĻžāϧāĻŋāĻ•āĻžāϰ āĻĨāĻžāϕ⧇āĨ¤ āφāĻŽāĻžāĻĻ⧇āϰ āĻļ⧁āϧ⧁āĻŽāĻžāĻ¤ā§āϰ āĻāĻ• āϧāϰāύ⧇āϰ āĻ…āĻĒāĻžāϰ⧇āϟāϰ āφāϛ⧇: `+`āĨ¤ āωāĻĒāϰāĻ¨ā§āϤ⧁, āĻ…ā§āϝāĻžāϏ⧋āϏāĻŋāϝāĻŧ⧇āϟāĻŋāĻ­āĻŋāϟāĻŋ āĻŦāĻžāĻŽ āĻĨ⧇āϕ⧇ āĻĄāĻžāύāĨ¤ -`3 + 4` gets evaluated first. This results in the number `7`. +ā§§āĻŽā§‡ `3 + 4` āĻŽā§‚āĻ˛ā§āϝāĻžāϝāĻŧāύ āĻ•āϰāĻž āĻšāϝāĻŧāĨ¤ āĻāϰ āĻĢāϞ⧇ āϏāĻ‚āĻ–ā§āϝāĻžāϟāĻŋ `7` āĻšāϝāĻŧāĨ¤ -`7 + '5'` results in `"75"` because of coercion. JavaScript converts the number `7` into a string, see question 15. We can concatenate two strings using the `+`operator. `"7" + "5"` results in `"75"`. +**āĻ•ā§‹ā§ŸāĻžāĻ°ā§āĻļāύ** āĻāϰ āĻĢāϞ⧇ `7 + '5'` āĻāϰ āĻĢāϞāĻžāĻĢāϞ āĻšā§Ÿ `"75"`āĨ¤ āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ `7` āύāĻŽā§āĻŦāϰāϟāĻŋāϕ⧇ āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āϝāĻŧ⧇ āϰ⧂āĻĒāĻžāĻ¨ā§āϤāϰ āĻ•āϰ⧇, [āĻĒā§āϰāĻļā§āύ 15 āĻĻ⧇āϖ⧁āύ](#15-āĻāϟāĻžāϰ-āφāωāϟāĻĒ⧁āϟ-āϕ⧋āύāϟāĻž)āĨ¤ āφāĻŽāϰāĻž `+` āĻ…āĻĒāĻžāϰ⧇āϟāϰ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ āĻĻ⧁āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āϕ⧇ āϏāĻ‚āϝ⧁āĻ•ā§āϤ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ `"7" + "5"` āĻĢāϞāĻžāĻĢāϞ⧇ `"75"`āĨ¤

--- -###### 49. What's the value of `num`? +###### 49. `num` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āϕ⧋āύāϟāĻŋ? ```javascript const num = parseInt('7*6', 10); @@ -1516,9 +1516,9 @@ const num = parseInt('7*6', 10); #### āωāĻ¤ā§āϤāϰ: C -Only the first number in the string is returned. Based on the _radix_ (the second argument in order to specify what type of number we want to parse it to: base 10, hexadecimal, octal, binary, etc.), the `parseInt` checks whether the characters in the string are valid. Once it encounters a character that isn't a valid number in the radix, it stops parsing and ignores the following characters. +āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻāϰ āĻļ⧁āϧ⧁āĻŽāĻžāĻ¤ā§āϰ āĻĒā§āϰāĻĨāĻŽ āϏāĻ‚āĻ–ā§āϝāĻžāϟāĻŋ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇āĨ¤ _radix_ āĻāϰ āωāĻĒāϰ āĻ­āĻŋāĻ¤ā§āϤāĻŋ āĻ•āϰ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚-āĻāϰ āĻ…āĻ•ā§āώāϰāϗ⧁āϞāĻŋ āĻŦ⧈āϧ āĻ•āĻŋāύāĻž āϤāĻž āĻĒāϰ⧀āĻ•ā§āώāĻž āĻ•āϰ⧇ (⧍⧟ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟāχ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻ•āϰ⧇ āφāĻŽāϰāĻž āϕ⧋āύ āϧāϰāύ⧇āϰ āϏāĻ‚āĻ–ā§āϝāĻžāϕ⧇ āĻĒāĻžāĻ°ā§āϏ āĻ•āϰāϤ⧇ āϚāĻžāχ: āĻĄā§‡āϏāĻŋāĻŽāĻžāϞ - 10, āĻšā§‡āĻ•ā§āϏāĻžāĻĄā§‡āϏāĻŋāĻŽāĻžāϞ - 16, āĻ…āĻ•ā§āϟāĻžāϞ - 8, āĻŦāĻžāχāύāĻžāϰāĻŋ - 2, āχāĻ¤ā§āϝāĻžāĻĻāĻŋ)āĨ¤ āĻāϟāĻŋ āϝāĻ–āύ āĻāĻ•āĻŦāĻžāϰ āĻāĻŽāύ āĻāĻ•āϟāĻŋ āĻ…āĻ•ā§āώāϰ⧇āϰ āĻŽā§āĻ–ā§‹āĻŽā§āĻ–āĻŋ āĻšāϝāĻŧ āϝāĻž āϰ⧇āĻĄāĻŋāĻ•ā§āϏ⧇ āĻāĻ•āϟāĻŋ āĻŦ⧈āϧ āϏāĻ‚āĻ–ā§āϝāĻž āύāϝāĻŧ, āϤāĻ–āύ āĻĒāĻžāĻ°ā§āϏāĻŋāĻ‚ āĻŦāĻ¨ā§āϧ āĻ•āϰ⧇ āĻĻā§‡ā§Ÿ āĻāĻŦāĻ‚ āĻĒāϰāĻŦāĻ°ā§āϤāĻŋ āĻ…āĻ•ā§āώāϰāϗ⧁āϞāĻŋāϕ⧇ āωāĻĒ⧇āĻ•ā§āώāĻž āĻ•āϰ⧇āĨ¤ -`*` is not a valid number. It only parses `"7"` into the decimal `7`. `num` now holds the value of `7`. +`*` āĻāĻ•āϟāĻŋ āĻŦ⧈āϧ āϏāĻ‚āĻ–ā§āϝāĻž āύāϝāĻŧāĨ¤ āĻāϟāĻŋ āĻļ⧁āϧ⧁āĻŽāĻžāĻ¤ā§āϰ `"7"` āϕ⧇ āĻĄā§‡āϏāĻŋāĻŽāĻžāϞ `7`-āĻ āĻĒāĻžāĻ°ā§āϏ āĻ•āϰ⧇āĨ¤ `num` āĻŽāĻžāύ āϤāĻžāχ `7`āĨ¤

@@ -1544,9 +1544,9 @@ Only the first number in the string is returned. Based on the _radix_ (the secon #### āωāĻ¤ā§āϤāϰ: C -When mapping over the array, the value of `num` is equal to the element it’s currently looping over. In this case, the elements are numbers, so the condition of the if statement `typeof num === "number"` returns `true`. The map function creates a new array and inserts the values returned from the function. +āĻ…ā§āϝāĻžāϰ⧇āϰ āωāĻĒāϰ āĻŽā§āϝāĻžāĻĒāĻŋāĻ‚ āĻ•āϰāĻžāϰ āϏāĻŽāϝāĻŧ, `num` āĻāϰ āĻŽāĻžāύāϟāĻŋ āĻŦāĻ°ā§āϤāĻŽāĻžāύ⧇ āϞ⧁āĻĒ āĻ•āϰāĻž āĻšāĻšā§āϛ⧇ āϏ⧇āχ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āϏāĻŽāĻžāύāĨ¤ āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟāϗ⧁āϞ⧋ āϏāĻ‚āĻ–ā§āϝāĻž, āϤāĻžāχ if āĻ¸ā§āĻŸā§‡āϟāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āĻļāĻ°ā§āϤāϟāĻŋ`typeof num === "number"` - `true` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤ āĻŽā§āϝāĻžāĻĒ āĻĢāĻžāĻ‚āĻļāύ āĻāĻ•āϟāĻŋ āύāϤ⧁āύ āĻ…ā§āϝāĻžāϰ⧇ āϤ⧈āϰāĻŋ āĻ•āϰ⧇ āĻāĻŦāĻ‚ āĻĢāĻžāĻ‚āĻļāύ āĻĨ⧇āϕ⧇ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻž āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞ⧋ āϏ⧇āϟāĻžāϤ⧇ āϝ⧁āĻ•ā§āϤ āĻ•āϰ⧇āĨ¤ -However, we don’t return a value. When we don’t return a value from the function, the function returns `undefined`. For every element in the array, the function block gets called, so for each element we return `undefined`. +āĻ…āĻ¨ā§āϝāĻĻāĻŋāϕ⧇, āφāĻŽāϰāĻž āϕ⧋āύ āĻ­ā§āϝāĻžāϞ⧁āχ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻŋ āύāĻŋāĨ¤ āϝāĻ–āύ āĻĢāĻžāĻ‚āĻļāύ āĻĨ⧇āϕ⧇ āϕ⧋āύ āĻāĻ•āϟāĻŋ āĻ­ā§āϝāĻžāϞ⧁ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻž āĻšā§Ÿ āύāĻž, āĻĢāĻžāĻ‚āĻļāύ `undefined` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤ āĻ…ā§āϝāĻžāϰ⧇āϰ āĻĒā§āϰāϤāĻŋāϟāĻŋ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āϜāĻ¨ā§āϝ, āĻĢāĻžāĻ‚āĻļāύ āĻŦā§āϞāĻ• āĻ•āϞ āĻ•āϰāĻž āĻšāϝāĻŧ, āϤāĻžāχ āĻĒā§āϰāϤāĻŋāϟāĻŋ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āϜāĻ¨ā§āϝ āφāĻŽāϰāĻž `undefined` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻ›āĻŋāĨ¤

From 5a217b412b30c94ac2e01c7ca0808572fd6f242c Mon Sep 17 00:00:00 2001 From: iamsaief Date: Mon, 27 May 2024 04:54:03 +0600 Subject: [PATCH 04/12] added translation till 65 --- bn-BD/README_bn-BD.md | 80 +++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/bn-BD/README_bn-BD.md b/bn-BD/README_bn-BD.md index 6eb10aab..1f798452 100644 --- a/bn-BD/README_bn-BD.md +++ b/bn-BD/README_bn-BD.md @@ -1579,11 +1579,11 @@ console.log(person, birthYear); #### āωāĻ¤ā§āϤāϰ: A -Arguments are passed by _value_, unless their value is an object, then they're passed by _reference_. `birthYear` is passed by value, since it's a string, not an object. When we pass arguments by value, a _copy_ of that value is created (see question 46). +āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟāϏāϗ⧁āϞ⧋ āĻšāϞ āĻĒāĻžāϏāĻĄ āĻŦāĻžāχ _āĻ­ā§āϝāĻžāϞ⧁_, āϝāĻĻāĻŋ āύāĻž āϤāĻžāϰāĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻšā§Ÿ, āϤāĻŦ⧇ āϤāĻžāϰāĻž āĻĒāĻžāϏāĻĄ āĻŦāĻžāχ _āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ_āĨ¤ āϝ⧇āĻšā§‡āϤ⧁ `birthYear` āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻāϟāĻŋ āĻĒāĻžāϏāĻĄ āĻŦāĻžāχ āĻ­ā§āϝāĻžāϞ⧁āĨ¤ āϝāĻ–āύ āφāĻŽāϰāĻž āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟāϏāϗ⧁āϞ⧋ āĻĒāĻžāϏ āĻ•āϰāĻŋ _āĻ­ā§āϝāĻžāϞ⧁_ āĻšāĻŋāϏ⧇āĻŦ⧇, āϐ āĻ­ā§āϝāĻžāϞ⧁āϰ āĻāĻ•āϟāĻŋ _āĻ•āĻĒāĻŋ_ āϤ⧈āϰāĻŋ āĻšā§ŸāĨ¤ [(āĻĒā§āϰāĻļā§āύ ā§Ēā§Ŧ āĻĻ⧇āϖ⧁āύ)](#46-āĻāϟāĻžāϰ-āφāωāϟāĻĒ⧁āϟ-āϕ⧋āύāϟāĻž) -The variable `birthYear` has a reference to the value `"1997"`. The argument `year` also has a reference to the value `"1997"`, but it's not the same value as `birthYear` has a reference to. When we update the value of `year` by setting `year` equal to `"1998"`, we are only updating the value of `year`. `birthYear` is still equal to `"1997"`. +`birthYear` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞāϟāĻŋāϰ āĻ•āĻžāϛ⧇ `"1997"` āĻ­ā§āϝāĻžāϞ⧁āϰ āĻāĻ•āϟāĻŋ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āφāϛ⧇āĨ¤ `year` āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āĻ•āĻžāϛ⧇āĻ“ `"1997"` āĻ­ā§āϝāĻžāϞ⧁āϰ āĻāĻ•āϟāĻŋ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āφāϛ⧇, āĻ•āĻŋāĻ¨ā§āϤ⧁ āĻĻ⧁āϟāĻŋ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āĻāĻ•āĻŋ āύ⧟āĨ¤ āĻŽāĻžāύ⧇ āĻšāϞ, āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āϭ⧇āϤāϰ⧇ āφāĻŽāϰāĻž āϝāĻ–āύ `year` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇ āφāĻĒāĻĄā§‡āϟ āĻ•āϰāĻ›āĻŋ `"1998"` āĻāϰ āϏāĻŽāĻžāύ āĻ•āϰ⧇, āφāĻŽāϰāĻž āϕ⧇āĻŦāϞ `year` āĻāϰ āĻ­ā§āϝāĻžāϞāĻŋāϟāĻŋāχ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāĻ›āĻŋāĨ¤ `birthYear` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻāĻ–āύ⧋ āϏāĻŽāĻžāύ āĻšāĻšā§āϛ⧇ `"1997"`āĨ¤ -The value of `person` is an object. The argument `member` has a (copied) reference to the _same_ object. When we modify a property of the object `member` has a reference to, the value of `person` will also be modified, since they both have a reference to the same object. `person`'s `name` property is now equal to the value `"Lydia"` +āĻ…āĻ¨ā§āϝāĻĻāĻŋāϕ⧇, `person` āĻšāϞ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāĨ¤ āĻāχ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āĻĒāĻžāϏ āĻšā§Ÿā§‡āϛ⧇ `member` āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟāĻŋāϟāĻŋāϰ āĻ•āĻžāϛ⧇āĨ¤ āϝāĻ–āύ āφāĻŽāϰāĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϕ⧋āύ āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋāϕ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāĻ›āĻŋ āϝ⧇āϟāĻžāϰ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āφāϛ⧇ `member` āĻāϰ āĻ•āĻžāϛ⧇, āϤāĻžāχ `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāĻ“ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻšāĻšā§āϛ⧇ āϝāĻžāĻšā§āϛ⧇āĨ¤ āϝ⧇āĻšā§‡āϤ⧁ āϤāĻžāĻĻ⧇āϰ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āĻāĻ•āχāĨ¤ āĻĢāϞ⧇ `person`-āĻāϰ `name` āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϟāĻŋ āĻāĻ–āύ āϏāĻŽāĻžāύ āĻšāϞ `"Lydia"`āĨ¤

@@ -1619,9 +1619,9 @@ sayHi(); #### āωāĻ¤ā§āϤāϰ: D -With the `throw` statement, we can create custom errors. With this statement, you can throw exceptions. An exception can be a string, a number, a boolean or an object. In this case, our exception is the string `'Hello world!'`. +`throw` āĻ¸ā§āĻŸā§‡āϟāĻŽā§‡āĻ¨ā§āϟ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ āφāĻŽāϰāĻž āĻ•āĻžāĻ¸ā§āϟāĻŽ āĻāϰāϰāϏ āϤ⧈āϰāĻŋ āĻ•āϰ⧇ āĻāĻ•ā§āϏāϏ⧇āĻĒāĻļāύ āĻĨā§āϰ⧋ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ āĻāĻ•ā§āϏāϏ⧇āĻĒāĻļāύāϏ āĻšāϤ⧇ āĻĒāĻžāϰ⧇ **string**, **number**, **boolean**, āĻ…āĻĨāĻŦāĻž āĻāĻ•āϟāĻŋ **āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ** āĨ¤ āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āĻāĻ•ā§āϏāϏ⧇āĻĒāĻļāύ āĻšāϞ āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ `'Hello world!'`āĨ¤ -With the `catch` statement, we can specify what to do if an exception is thrown in the `try` block. An exception is thrown: the string `'Hello world!'`. `e` is now equal to that string, which we log. This results in `'Oh an error: Hello world!'`. +`catch` āĻ¸ā§āĻŸā§‡āϟāĻŽā§‡āĻ¨ā§āϟ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ āφāĻŽāϰāĻž āĻāϟāĻž āύāĻŋāĻ°ā§āĻĻāĻŋāĻ¸ā§āϟ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ āϝ⧇ _āĻ•āĻŋ āĻ•āϰāĻž āĻšāĻŦ⧇_ āϝāĻ–āύ `try` āĻŦā§āϞāĻ• āĻĨ⧇āϕ⧇ āϕ⧋āύ āĻāĻ•ā§āϏāϏ⧇āĻĒāĻļāύ āĻĨā§āϰ⧋ āĻ•āϰāĻž āĻšā§ŸāĨ¤ āĻāĻ•ā§āϏāϏ⧇āĻĒāĻļāύ āĻĨā§āϰ⧋ āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇āσ `'Hello world!'` āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āϟāĻŋāĨ¤ `e` āĻšāϞ āĻāχ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āϟāĻŋāϰ āϏāĻŽāĻžāύ, āϝ⧇āϟāĻž āϞāĻ— āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇āĨ¤ āϤāĻžāχ āĻĢāϞāĻžāĻĢāϞ āĻšā§Ÿā§‡āϛ⧇ `'Oh an error: Hello world!'`āĨ¤

@@ -1650,9 +1650,9 @@ console.log(myCar.make); #### āωāĻ¤ā§āϤāϰ: B -When a constructor function is called with the `new` keyword, it creates an object and sets the `this` keyword to refer to that object. By default, if the constructor function doesn't explicitly return anything, it will return the newly created object. +āϝāĻ–āύ āĻāĻ•āϟāĻŋ āĻ•āύāĻ¸ā§āĻŸā§āϰāĻžāĻ•ā§āϟāϰ āĻĢāĻžāĻ‚āĻļāύāϕ⧇ `new` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĻāĻŋāϝāĻŧ⧇ āĻ•āϞ āĻ•āϰāĻž āĻšāϝāĻŧ, āϤāĻ–āύ āĻāϟāĻŋ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āϤ⧈āϰāĻŋ āĻ•āϰ⧇ āĻāĻŦāĻ‚ āĻāϟāĻžāϕ⧇ āϰ⧇āĻĢāĻžāϰ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ `this` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄāϟāĻŋ āϏ⧇āϟ āĻ•āϰ⧇āĨ¤ āĻĄāĻŋāĻĢāĻ˛ā§āϟāϰ⧂āĻĒ⧇, āϝāĻĻāĻŋ āĻ•āύāĻ¸ā§āĻŸā§āϰāĻžāĻ•ā§āϟāϰ āĻĢāĻžāĻ‚āĻļāύ āϏāϰāĻžāϏāϰāĻŋ āĻ•āĻŋāϛ⧁ āϰāĻŋāϟāĻžāĻ°ā§āύ āύāĻž āĻ•āϰ⧇, āϤāĻŦ⧇ āĻāϟāĻŋ āύāϤ⧁āύ āϤ⧈āϰāĻŋāĻ•ā§ƒāϤ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇āχ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻŦ⧇āĨ¤ -In this case, the constructor function `Car` explicitly returns a new object with `make` set to `"Maserati"`, which overrides the default behavior. Therefore, when `new Car()` is called, the _returned_ object is assigned to `myCar`, resulting in the output being `"Maserati"` when `myCar.make` is accessed. +āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āĻ•āύāĻ¸ā§āĻŸā§āϰāĻžāĻ•ā§āϟāϰ āĻĢāĻžāĻ‚āĻļāύ `Car` āϏāϰāĻžāϏāϰāĻŋ āĻāĻ•āϟāĻŋ āύāϤ⧁āύ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ āϝāĻžāϰ āϏāĻžāĻĨ⧇ `make` āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϕ⧇ āϏ⧇āϟ āĻ•āϰāĻž āĻšā§Ÿ `"Maserati"`, āϝāĻž āĻĄāĻŋāĻĢāĻ˛ā§āϟ āφāϚāϰāύāϕ⧇ āĻ“āĻ­āĻžāϰāϰāĻžāχāĻĄ āĻ•āϰ⧇āĨ¤ āϤāĻžāχ, āϝāĻ–āύ `new Car()` āĻ•āϞ āĻ•āϰāĻž āĻšāϝāĻŧ, āϤāĻ–āύ _returned_ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϟāĻŋ `myCar`-āĻ āĻ…ā§āϝāĻžāϏāĻžāχāύ āĻ•āϰāĻž āĻšāϝāĻŧ, āϝāĻžāϰ āĻĢāϞ⧇ `myCar.make`āϕ⧇ āĻ…ā§āϝāĻžāĻ•ā§āϏ⧇āϏ āĻ•āϰāĻž āĻšāϞ⧇ āφāωāϟāĻĒ⧁āϟ `"Maserati"` āĻšāϝāĻŧāĨ¤

@@ -1680,18 +1680,18 @@ console.log(typeof y); #### āωāĻ¤ā§āϤāϰ: A -`let x = (y = 10);` is actually shorthand for: +`let x = (y = 10);` āφāϏāϞ⧇ āĻšāĻšā§āϛ⧇ āύāĻŋāĻšā§‡āϰ āωāĻ˛ā§āϞ⧇āĻ–āĻŋāϤ āĻ…āĻ‚āĻļ⧇āϰ āϏāĻ‚āĻ•ā§āώāĻŋāĻĒā§āϤāϰ⧂āĻĒ āσ ```javascript y = 10; let x = y; ``` -When we set `y` equal to `10`, we actually add a property `y` to the global object (`window` in the browser, `global` in Node). In a browser, `window.y` is now equal to `10`. +āφāĻŽāϰāĻž āϝāĻ–āύ `y` āϕ⧇ āϏ⧇āϟ āĻ•āϰāĻŋ `10` āĻāϰ āϏāĻŽāĻžāύ āϤāĻ–āύ āφāĻŽāϰāĻž āφāϏāϞ⧇ āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āĻāĻ•āϟāĻŋ āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋ `y` āϝ⧋āĻ— āĻ•āϰāĻŋ (āĻŦā§āϰāĻžāωāϜāĻžāϰ⧇ `āωāχāĻ¨ā§āĻĄā§‹`, āύ⧋āĻĄā§‡ `āĻ—ā§āϞ⧋āĻŦāĻžāϞ`)āĨ¤ āĻāĻ•āϟāĻŋ āĻŦā§āϰāĻžāωāϜāĻžāϰ⧇, `window.y` āĻāĻ–āύ `10` āĻāϰ āϏāĻŽāĻžāύāĨ¤ -Then, we declare a variable `x` with the value of `y`, which is `10`. Variables declared with the `let` keyword are _block scoped_, they are only defined within the block they're declared in; the immediately invoked function expression (IIFE) in this case. When we use the `typeof` operator, the operand `x` is not defined: we are trying to access `x` outside of the block it's declared in. This means that `x` is not defined. Values who haven't been assigned a value or declared are of type `"undefined"`. `console.log(typeof x)` returns `"undefined"`. +āϤāĻžāϰāĻĒāϰ, āφāĻŽāϰāĻž `y` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āϏāĻš āĻāĻ•āϟāĻŋ āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞ `x` āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰāĻŋ, āϝāĻž `10`āĨ¤ `let` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄā§‡āϰ āϏāĻžāĻĨ⧇ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰāĻž āϭ⧇āϰāĻŋāϝāĻŧ⧇āĻŦāϞāϗ⧁āϞāĻŋ āĻšāϞ _block scoped_, āϤāĻžāϰāĻž āĻļ⧁āϧ⧁āĻŽāĻžāĻ¤ā§āϰ āϝ⧇ āĻŦā§āϞāϕ⧇ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰāĻž āĻšāϝāĻŧ⧇āϛ⧇ āϤāĻžāϰ āĻŽāĻ§ā§āϝ⧇āχ āĻĄāĻŋāĻĢāĻžāχāύāĻ•ā§ƒāϤ (āϏāĻ‚āĻœā§āĻžāĻžā§ŸāĻŋāϤ) āĻĨāĻžāĻ•āĻŦ⧇; āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ āχāĻŽāĻŋāĻĄāĻŋā§Ÿā§‡āϟāϞāĻŋ āχāύāĻ­ā§‹āĻ•āĻĄ āĻĢāĻžāĻ‚āĻļāύ āĻāĻ•ā§āϏāĻĒā§āϰ⧇āĻļāύ (IIFE)āĨ¤ āϝāĻ–āύ āφāĻŽāϰāĻž `typeof` āĻ…āĻĒāĻžāϰ⧇āϟāϰ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāĻ›āĻŋ, āϏ⧇āĻ–āĻžāύ⧇ āĻ…āĻĒāĻžāϰ⧇āĻ¨ā§āĻĄ `x` āĻĄāĻŋāĻĢāĻžāχāύ āĻšā§ŸāύāĻŋ: āφāĻŽāϰāĻž āϝ⧇ āĻŦā§āϞāϕ⧇ āĻāϟāĻŋ āĻ˜ā§‹āώāĻŖāĻž āĻ•āϰāĻž āĻšāϝāĻŧ⧇āϛ⧇ āϤāĻžāϰ āĻŦāĻžāχāϰ⧇ `x`-āϕ⧇ āĻ…ā§āϝāĻžāĻ•ā§āϏ⧇āϏ āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāĻ›āĻŋāĨ¤ āĻāĻ–āĻžāύ⧇ `x` āĻĄāĻŋāĻĢāĻžāχāύ āĻšā§ŸāύāĻŋāĨ¤ āϝ⧇ āĻŽāĻžāύāϗ⧁āϞāĻŋāϕ⧇ āĻāĻ•āϟāĻŋ āĻŽāĻžāύ āĻ…ā§āϝāĻžāϏāĻžāχāύ āĻ•āϰāĻž āĻšāϝāĻŧāύāĻŋ āĻŦāĻž āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰāĻž āĻšāϝāĻŧāύāĻŋ āϏ⧇āϗ⧁āϞāĻŋ `"undefined"` āĻšā§Ÿ āϟāĻžāχāĻĒ⧇āϰāĨ¤ āϤāĻžāχ `console.log(typeof x)` `"undefined"` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āϛ⧇āĨ¤ -However, we created a global variable `y` when setting `y` equal to `10`. This value is accessible anywhere in our code. `y` is defined, and holds a value of type `"number"`. `console.log(typeof y)` returns `"number"`. +āĻ…āĻ¨ā§āϝāĻĻāĻŋāϕ⧇, āφāĻŽāϰāĻž `y` āϕ⧇ `10` āĻāϰ āϏāĻŽāĻžāύ āϏ⧇āϟ āĻ•āϰ⧇ āĻāĻ•āϟāĻŋ āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ­ā§āϝ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞ āϤ⧈āϰāĻŋ āĻ•āϰ⧇āĻ›āĻŋ `y`āĨ¤ āĻāχ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āϕ⧋āĻĄā§‡āϰ āϝ⧇āϕ⧋āύ āĻ…āĻ‚āĻļ āĻĨ⧇āϕ⧇āχ āĻ…ā§āϝāĻžāĻ•ā§āϏ⧇āϏ āĻ•āϰāĻž āϝāĻžāĻŦ⧇āĨ¤ `y` āϝ⧇āĻšā§‡āϤ⧁ āĻāĻ•āϟāĻŋ `"number"` āϟāĻžāχāĻĒ āĻĻāĻŋā§Ÿā§‡ āĻĄāĻŋāĻĢāĻžāχāύ āĻšā§Ÿā§‡āϛ⧇, `console.log(typeof y)` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āϛ⧇ `"number"`āĨ¤

@@ -1730,9 +1730,9 @@ pet.bark(); #### āωāĻ¤ā§āϤāϰ: A -We can delete properties from objects using the `delete` keyword, also on the prototype. By deleting a property on the prototype, it is not available anymore in the prototype chain. In this case, the `bark` function is not available anymore on the prototype after `delete Dog.prototype.bark`, yet we still try to access it. +`delete` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϏ āĻŽā§āϛ⧇ āĻĢ⧇āϞāϤ⧇ āĻĒāĻžāϰāĻŋ, āĻāĻ•āχāĻ­āĻžāĻŦ⧇ āĻĒā§āϰ⧋āĻŸā§‹āϟāĻžāχāĻĒ āĻĨ⧇āϕ⧇āĻ“ āĻŽā§āϛ⧇ āĻĢ⧇āϞāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ āĻāĻ•āϟāĻŋ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϕ⧇ āĻĒā§āϰ⧋āĻŸā§‹āϟāĻžāχāĻĒ āĻĨ⧇āϕ⧇ āĻŽā§āϛ⧇ āĻĢ⧇āϞāϞ⧇ āϤāĻžāϕ⧇ āĻĒā§āϰ⧋āĻŸā§‹āϟāĻžāχāĻĒ āĻšā§‡āχāύ⧇ āφāϰ āĻĒāĻžāĻ“ā§ŸāĻž āϝāĻžā§Ÿ āύāĻžāĨ¤ āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, `delete Dog.prototype.bark`-āĻāϰ āĻĒāϰ⧇ `bark` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻĒā§āϰ⧋āĻŸā§‹āϟāĻžāχāĻĒ āĻšā§‡āχāύ⧇ āφāϰ āύ⧇āχ, āϤāĻŦ⧁āĻ“ āφāĻŽāϰāĻž āĻāϟāĻŋ āĻ…ā§āϝāĻžāĻ•ā§āϏ⧇āϏ āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰ⧇āĻ›āĻŋāĨ¤ -When we try to invoke something that is not a function, a `TypeError` is thrown. In this case `TypeError: pet.bark is not a function`, since `pet.bark` is `undefined`. +āϝāĻ–āύ āφāĻŽāϰāĻž āĻĢāĻžāĻ‚āĻļāύ āύāϝāĻŧ āĻāĻŽāύ āϕ⧋āύ⧋ āĻ•āĻŋāϛ⧁āϕ⧇ āĻ•āϞ āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāĻŋ, āϤāĻ–āύ āĻāĻ•āϟāĻŋ `TypeError` āĻĨā§āϰ⧋ āĻ•āϰāĻž āĻšāϝāĻŧāĨ¤ āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ `TypeError: pet.bark is not a function`, āϝ⧇āĻšā§‡āϤ⧁ `pet.bark` `undefined`āĨ¤

@@ -1757,9 +1757,9 @@ console.log(set); #### āωāĻ¤ā§āϤāϰ: D -The `Set` object is a collection of _unique_ values: a value can only occur once in a set. +`Set` āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϟāĻŋ āĻšāϞ _āĻ…āύāĻ¨ā§āϝ_ āĻ­ā§āϝāĻžāϞ⧁āϏāĻŽā§āĻšā§‡āϰ āĻāĻ•āϟāĻŋ āϏāĻ‚āĻ—ā§āϰāĻš: āĻāĻ•āϟāĻŋ āϏ⧇āĻŸā§‡ āĻāĻ•āχ āĻŽāĻžāύ āϕ⧇āĻŦāϞ āĻāĻ•āĻŦāĻžāϰāχ āĻĨāĻžāĻ•āϤ⧇ āĻĒāĻžāϰ⧇āĨ¤ -We passed the iterable `[1, 1, 2, 3, 4]` with a duplicate value `1`. Since we cannot have two of the same values in a set, one of them is removed. This results in `{1, 2, 3, 4}`. +āφāĻŽāϰāĻž āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇ `[1, 1, 2, 3, 4]` āĻĒāĻžāϏ āĻ•āϰ⧇āĻ›āĻŋ āϝ⧇āĻ–āĻžāύ⧇ āĻāĻ•āϟāĻŋ āĻĄā§āĻĒā§āϞāĻŋāϕ⧇āϟ āĻŽāĻžāύ `1` āφāϛ⧇āĨ¤ āϝ⧇āĻšā§‡āϤ⧁ āφāĻŽāĻžāĻĻ⧇āϰ āĻāĻ•āϟāĻŋ āϏ⧇āĻŸā§‡ āĻāĻ•āχ āĻŽāĻžāύ āĻĻ⧁āϟāĻŋ āĻĨāĻžāĻ•āϤ⧇ āĻĒāĻžāϰ⧇ āύāĻž, āϤāĻžāĻĻ⧇āϰ āĻŽāĻ§ā§āϝ⧇ āĻāĻ•āϟāĻŋ āϏāϰāĻžāύ⧋ āĻšāϝāĻŧāĨ¤ āϤāĻžāχ āĻĢāϞāĻžāĻĢāϞ āĻšā§Ÿāϛ⧇ `{1, 2, 3, 4}`āĨ¤

@@ -1793,9 +1793,9 @@ console.log(myCounter); #### āωāĻ¤ā§āϤāϰ: C -An imported module is _read-only_: you cannot modify the imported module. Only the module that exports them can change its value. +āĻāĻ•āϟāĻŋ āχāĻŽā§āĻĒā§‹āĻ°ā§āϟ āĻ•āϰāĻž āĻŽāĻĄāĻŋāωāϞ āĻšāϞ _āĻļ⧁āϧ⧁āĻŽāĻžāĻ¤ā§āϰ āĻĒāĻĄāĻŧāĻž āϝāĻžā§Ÿ_: āφāĻĒāύāĻŋ āχāĻŽā§āĻĒā§‹āĻ°ā§āϟ āĻ•āϰāĻž āĻŽāĻĄāĻŋāωāϞ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŦ⧇āύ āύāĻžāĨ¤ āĻļ⧁āϧ⧁āĻŽāĻžāĻ¤ā§āϰ āϝ⧇ āĻŽāĻĄāĻŋāωāϞ āϤāĻžāĻĻ⧇āϰ āĻāĻ•ā§āϏāĻĒā§‹āĻ°ā§āϟ āĻ•āϰ⧇ āϏ⧇āχ āϕ⧇āĻŦāϞ āĻŽāĻžāύ⧇āϰ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āĨ¤ -When we try to increment the value of `myCounter`, it throws an error: `myCounter` is read-only and cannot be modified. +āϝāĻ–āύ āφāĻŽāϰāĻž `myCounter` āĻāϰ āĻŽāĻžāύ āĻŦ⧃āĻĻā§āϧāĻŋ āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāĻŋ, āĻāϟāĻŋ āĻāĻ•āϟāĻŋ āĻāϰāϰ āϛ⧁āĻĄāĻŧ⧇ āĻĻā§‡ā§ŸāĻž āĻšā§Ÿ: `myCounter` is read-only and cannot be modified.

@@ -1822,9 +1822,9 @@ console.log(delete age); #### āωāĻ¤ā§āϤāϰ: A -The `delete` operator returns a boolean value: `true` on a successful deletion, else it'll return `false`. However, variables declared with the `var`, `const`, or `let` keywords cannot be deleted using the `delete` operator. +`delete` āĻ…āĻĒāĻžāϰ⧇āϟāϰ āĻāĻ•āϟāĻŋ āĻŦ⧁āϞāĻŋāϝāĻŧāĻžāύ āĻŽāĻžāύ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇: āĻĄāĻŋāϞāĻŋāϟ āϏāĻĢāϞ āĻšāϞ⧇ `true`, āĻ…āĻ¨ā§āϝāĻĨāĻžāϝāĻŧ āĻāϟāĻŋ `false` āĻĒā§āϰāĻĻāĻžāύ āĻ•āϰāĻŦ⧇āĨ¤ āĻ…āĻ¨ā§āϝāĻĻāĻŋāϕ⧇, `var`, `const`, āĻŦāĻž `let` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄā§‡āϰ āĻĻāĻŋā§Ÿā§‡ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰāĻž āϭ⧇āϰāĻŋāϝāĻŧ⧇āĻŦāϞ `delete` āĻ…āĻĒāĻžāϰ⧇āϟāϰ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ āĻŽā§āϛ⧇ āĻĢ⧇āϞāĻž āϝāĻžā§Ÿ āύāĻžāĨ¤ -The `name` variable was declared with a `const` keyword, so its deletion is not successful: `false` is returned. When we set `age` equal to `21`, we actually added a property called `age` to the global object. You can successfully delete properties from objects this way, also the global object, so `delete age` returns `true`. +`name` āϭ⧇āϰāĻŋāϝāĻŧ⧇āĻŦāϞāϟāĻŋāϕ⧇ āĻāĻ•āϟāĻŋ `const` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĻāĻŋāϝāĻŧ⧇ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰāĻž āĻšāϝāĻŧ⧇āĻ›āĻŋāϞ, āϤāĻžāχ āĻāϟāĻŋ āĻŽā§āϛ⧇ āĻĢ⧇āϞāĻž āϏāĻĢāϞ āĻšāϝāĻŧāύāĻŋ: `false` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻž āĻšāϝāĻŧ⧇āϛ⧇āĨ¤ āϝāĻ–āύ āφāĻŽāϰāĻž `age` āϏāĻŽāĻžāύ `21` āϏ⧇āϟ āĻ•āϰāĻŋ, āφāĻŽāϰāĻž āφāϏāϞ⧇ āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ `age` āύāĻžāĻŽāĻ• āĻāĻ•āϟāĻŋ āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋ āϝ⧋āĻ— āĻ•āϰāĻŋāĨ¤ āφāĻĒāύāĻŋ āϏāĻĢāϞāĻ­āĻžāĻŦ⧇ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϗ⧁āϞ⧋ āĻĨ⧇āϕ⧇ āĻāχāĻ­āĻžāĻŦ⧇ āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋāϗ⧁āϞāĻŋ āĻŽā§āϛ⧇ āĻĢ⧇āϞāϤ⧇ āĻĒāĻžāϰ⧇āύ, āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻĨ⧇āϕ⧇āĻ“ āϤāĻžāχ `delete age` `true` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤

@@ -1850,7 +1850,7 @@ console.log(y); #### āωāĻ¤ā§āϤāϰ: C -We can unpack values from arrays or properties from objects through destructuring. For example: +āφāĻŽāϰāĻž āĻĄāĻŋāĻ¸ā§āĻŸā§āϰāĻžāĻ•āϚāĻžāϰ⧇āϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡ āĻ…ā§āϝāĻžāϰ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁ āĻŦāĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϏ āĻŦ⧇āϰ āĻ•āϰ⧇ āφāύāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ āωāĻĻāĻžāĻšāϰāĻŖ āĻ¸ā§āĻŦāϰ⧂āĻĒ: ```javascript [a, b] = [1, 2]; @@ -1858,7 +1858,7 @@ We can unpack values from arrays or properties from objects through destructurin -The value of `a` is now `1`, and the value of `b` is now `2`. What we actually did in the question, is: +`a`-āĻāϰ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻāĻ–āύ `1` āĻāĻŦāĻ‚ `b` -āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻāĻ–āύ `2`āĨ¤ āφāĻŽāϰāĻž āφāϏāϞ⧇ āĻāχ āĻĒā§āϰāĻļā§āύ⧇āϰ āĻŦ⧇āϞāĻžā§Ÿ āϝ⧇āϟāĻž āĻ•āϰ⧇āĻ›āĻŋāσ ```javascript [y] = [1, 2, 3, 4, 5]; @@ -1866,7 +1866,7 @@ The value of `a` is now `1`, and the value of `b` is now `2`. What we actually d -This means that the value of `y` is equal to the first value in the array, which is the number `1`. When we log `y`, `1` is returned. +āĻāϰ āĻŽāĻžāύ⧇ āĻšāϞ, `y` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āϏāĻŽāĻžāύ āĻšā§Ÿ āĻ…ā§āϝāĻžāϰ⧇āϰ ā§§āĻŽ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āĻ­ā§āϝāĻžāϞ⧁, āĻāχ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋāĻŋ āĻšāϞ `1` āϏāĻ‚āĻ–ā§āϝāĻžāϟāĻŋāĨ¤ āϤāĻžāχ `y` āϕ⧇ āϝāĻ–āύ āϞāĻ— āĻ•āϰāĻ›āĻŋ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻĒāĻžāχ `1`āĨ¤

@@ -1892,7 +1892,7 @@ console.log(admin); #### āωāĻ¤ā§āϤāϰ: B -It's possible to combine objects using the spread operator `...`. It lets you create copies of the key/value pairs of one object, and add them to another object. In this case, we create copies of the `user` object, and add them to the `admin` object. The `admin` object now contains the copied key/value pairs, which results in `{ admin: true, name: "Lydia", age: 21 }`. +āĻ¸ā§āĻĒā§āϰ⧇āĻĄ āĻ…āĻĒāĻžāϰ⧇āϟāϰ `...` āĻĻāĻŋā§Ÿā§‡ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϗ⧁āϞ⧋āϕ⧇ āĻāĻ•āĻ¤ā§āϰāĻŋāϤ āĻ•āϰāĻž āϏāĻŽā§āĻ­āĻŦāĨ¤ āĻāϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻ•āĻŋ/āĻ­ā§āϝāĻžāϞ⧁ āĻœā§‹ā§œāĻžāĻĻā§āĻŦā§Ÿā§‡āϰ āĻ•āĻĒāĻŋ āϤ⧈āϰāĻŋ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŦ⧇āύ āĻāĻŦāĻ‚ āĻ…āĻ¨ā§āϝ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āϤāĻžāĻĻ⧇āϰ āϝ⧁āĻ•ā§āϤ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŦ⧇āύāĨ¤ āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āφāĻŽāϰāĻž `user` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻ•āĻĒāĻŋ āϤ⧈āϰāĻŋ āĻ•āϰ⧇āĻ›āĻŋ āĻāĻŦāĻ‚ `admin` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āϝ⧁āĻ•ā§āϤ āĻ•āϰ⧇āĻ›āĻŋāĨ¤ āϤāĻžāχ `admin` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āĻāĻ–āύ āĻ•āĻŋ/āĻ­ā§āϝāĻžāϞ⧁ āĻœā§‹ā§œāĻžāϰ āĻ•āĻĒāĻŋāĻ“ āĻ°ā§Ÿā§‡āϛ⧇, āĻĢāϞ⧇ āϞāĻ— āĻ•āϰāĻžā§Ÿ `{ admin: true, name: "Lydia", age: 21 }` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻĒāĻžāχāĨ¤

@@ -1920,9 +1920,9 @@ console.log(Object.keys(person)); #### āωāĻ¤ā§āϤāϰ: B -With the `defineProperty` method, we can add new properties to an object, or modify existing ones. When we add a property to an object using the `defineProperty` method, they are by default _not enumerable_. The `Object.keys` method returns all _enumerable_ property names from an object, in this case only `"name"`. +`defineProperty` āĻŽā§‡āĻĨāĻĄā§‡āϰ āϏāĻžāĻšāĻžāĻ¯ā§āϝ⧇, āφāĻŽāϰāĻž āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āύāϤ⧁āύ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϏ āϝ⧋āĻ— āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ āĻŦāĻž āĻŦāĻŋāĻĻā§āϝāĻŽāĻžāύāϗ⧁āϞāĻŋāϕ⧇ āϏāĻ‚āĻļā§‹āϧāύ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ āϝāĻ–āύ āφāĻŽāϰāĻž `defineProperty` āĻŽā§‡āĻĨāĻĄā§‡āϰ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ āϕ⧋āύ⧋ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āĻāĻ•āϟāĻŋ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āϝ⧋āĻ— āĻ•āϰāĻŋ, āϤāĻ–āύ āϏ⧇āϗ⧁āϞāĻŋ āĻĄāĻŋāĻĢāĻ˛ā§āϟāϰ⧂āĻĒ⧇ _āĻ—āĻŖāύāĻžāϝ⧋āĻ—ā§āϝ āύāϝāĻŧ_ (_not enumerable_)āĨ¤ `Object.keys` āĻŽā§‡āĻĨāĻĄ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϏāĻŽāĻ¸ā§āϤ _āĻ—āĻŖāύāĻžāϝ⧋āĻ—ā§āϝ_ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϏ⧇āϰ āύāĻžāĻŽ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇, āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ āĻļ⧁āϧ⧁āĻŽāĻžāĻ¤ā§āϰ `"name"`āĨ¤ -Properties added using the `defineProperty` method are immutable by default. You can override this behavior using the `writable`, `configurable` and `enumerable` properties. This way, the `defineProperty` method gives you a lot more control over the properties you're adding to an object. +`defineProperty` āĻŽā§‡āĻĨāĻĄ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ āϝ⧋āĻ— āĻ•āϰāĻž āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϏāϗ⧁āϞāĻŋ āĻĄāĻŋāĻĢāĻ˛ā§āϟāϰ⧂āĻĒ⧇ āĻ…āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ⧀āϝāĻŧāĨ¤ āĻ āφāϚāϰāĻŖāϟāĻŋāϕ⧇ āφāĻĒāύāĻŋ āĻ“āĻ­āĻžāϰāϰāĻžāχāĻĄ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āύ `writable`, `configurable` āĻ“ `enumerable` āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϏāϗ⧁āϞāĻŋ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇āĨ¤ āĻāχāĻ­āĻžāĻŦ⧇, `defineProperty` āĻŽā§‡āĻĨāĻĄ āφāĻĒāύāĻžāϕ⧇ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āϝ⧇ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϏāϗ⧁āϞāĻŋ āϝ⧋āĻ— āĻ•āϰāϛ⧇āύ āϤāĻžāϰ āωāĻĒāϰ āĻ…āύ⧇āĻ• āĻŦ⧇āĻļāĻŋ āύāĻŋāϝāĻŧāĻ¨ā§āĻ¤ā§āϰāĻŖ āĻĻ⧇āϝāĻŧāĨ¤

@@ -1952,11 +1952,11 @@ console.log(data); #### āωāĻ¤ā§āϤāϰ: A -The second argument of `JSON.stringify` is the _replacer_. The replacer can either be a function or an array, and lets you control what and how the values should be stringified. +`JSON.stringify` āĻāϰ āĻĻā§āĻŦāĻŋāϤ⧀āϝāĻŧ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āĻšāϞ _replacer_āĨ¤ āϰāĻŋāĻĒā§āϞ⧇āϏāĻžāϰ āĻāĻ•āϟāĻŋ āĻĢāĻžāĻ‚āĻļāύ āĻŦāĻž āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇ āĻšāϤ⧇ āĻĒāĻžāϰ⧇ āĻāĻŦāĻ‚ āĻāϟāĻŋ āφāĻĒāύāĻžāϕ⧇ āύāĻŋāϝāĻŧāĻ¨ā§āĻ¤ā§āϰāĻŖ āĻ•āϰāϤ⧇ āĻĻ⧇āϝāĻŧ āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞ⧋ āĻ•āĻŋ āĻ“ āϕ⧀āĻ­āĻžāĻŦ⧇ āϤāĻžāϰāĻž āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āĻĢāĻžāχ āĻšāĻŦ⧇ āϏ⧇āϟāĻžāĨ¤ -If the replacer is an _array_, only the property names included in the array will be added to the JSON string. In this case, only the properties with the names `"level"` and `"health"` are included, `"username"` is excluded. `data` is now equal to `"{"level":19, "health":90}"`. +āϝāĻĻāĻŋ āϰāĻŋāĻĒā§āϞ⧇āϏāĻžāϰ āĻāĻ•āϟāĻŋ _array_ āĻšāϝāĻŧ, āĻļ⧁āϧ⧁āĻŽāĻžāĻ¤ā§āϰ āĻ…ā§āϝāĻžāϰ⧇āϤ⧇ āĻ…āĻ¨ā§āϤāĻ°ā§āϭ⧁āĻ•ā§āϤ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϏ⧇āϰ āύāĻžāĻŽāϗ⧁āϞāĻŋ JSON āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āϝāĻŧ⧇ āϝ⧋āĻ— āĻ•āϰāĻž āĻšāĻŦ⧇āĨ¤ āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āĻļ⧁āϧ⧁āĻŽāĻžāĻ¤ā§āϰ `"level"` āĻāĻŦāĻ‚ `"health"` āύāĻžāĻŽā§‡āϰ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϏāϗ⧁āϞāĻŋ āĻ…āĻ¨ā§āϤāĻ°ā§āϭ⧁āĻ•ā§āϤ āĻ•āϰāĻž āĻšāϝāĻŧ⧇āϛ⧇, `"username"` āĻŦāĻžāĻĻ āĻĻ⧇āĻ“āϝāĻŧāĻž āĻšāϝāĻŧ⧇āϛ⧇āĨ¤ āϤāĻžāχ `data` āĻāĻ–āύ `"{"level":19, "health":90}"` āĻāϰ āϏāĻŽāĻžāύāĨ¤ -If the replacer is a _function_, this function gets called on every property in the object you're stringifying. The value returned from this function will be the value of the property when it's added to the JSON string. If the value is `undefined`, this property is excluded from the JSON string. +āϝāĻĻāĻŋ āϰāĻŋāĻĒā§āϞ⧇āϏāĻžāϰāϟāĻŋ āĻāĻ•āϟāĻŋ _function_ āĻšāϝāĻŧ, āϤāĻžāĻšāϞ⧇ āφāĻĒāύāĻŋ āϝ⧇ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āĻĢāĻžāχ āĻ•āϰāϛ⧇āύ āϤāĻžāϰ āĻĒā§āϰāϤāĻŋāϟāĻŋ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϏ⧇āϰ āϜāĻ¨ā§āϝ āĻāχ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻ•āϞ āĻ•āϰāĻž āĻšāĻŦ⧇āĨ¤ āĻāχ āĻĢāĻžāĻ‚āĻļāύ āĻĨ⧇āϕ⧇ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻž āĻ­ā§āϝāĻžāϞ⧁āχ āĻšāĻŦ⧇ āϏ⧇āχ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϏ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁ āϝāĻ–āύ āĻāϟāĻŋ JSON āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚-āĻ āϝ⧋āĻ— āĻ•āϰāĻž āĻšāϝāĻŧāĨ¤ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āϝāĻĻāĻŋ `undefined` āĻšāϝāĻŧ, āϤāĻžāĻšāϞ⧇ āĻāχ āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋāϟāĻŋ JSON āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻĨ⧇āϕ⧇ āĻŦāĻžāĻĻ āĻĻ⧇āĻ“āϝāĻŧāĻž āĻšāĻŦ⧇āĨ¤

@@ -1988,9 +1988,9 @@ console.log(num2); #### āωāĻ¤ā§āϤāϰ: A -The unary operator `++` _first returns_ the value of the operand, _then increments_ the value of the operand. The value of `num1` is `10`, since the `increaseNumber` function first returns the value of `num`, which is `10`, and only increments the value of `num` afterward. +āχāωāύāĻžāϰāĻŋ āĻ…āĻĒāĻžāϰ⧇āϟāϰ `++` _āĻĒā§āϰāĻĨāĻŽā§‡ āĻ…āĻĒāĻžāϰ⧇āĻ¨ā§āĻĄā§‡āϰ āĻŽāĻžāύ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇_, āϤāĻžāϰāĻĒāϰ āĻ…āĻĒāĻžāϰ⧇āĻ¨ā§āĻĄā§‡āϰ āĻŽāĻžāύ āĻŦ⧃āĻĻā§āϧāĻŋ āĻ•āϰ⧇āĨ¤ `num1`-āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ `10`, āϝ⧇āĻšā§‡āϤ⧁ `increaseNumber` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻĒā§āϰāĻĨāĻŽā§‡ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋāϕ⧇ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇, āϝ⧇āϟāĻž āĻšāϞ `10`, āϤāĻžāϰāĻĒāϰāχ āϕ⧇āĻŦāϞ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋāϕ⧇ āĻŦ⧃āĻĻā§āϧāĻŋ āĻ•āϰ⧇āĨ¤ -`num2` is `10`, since we passed `num1` to the `increasePassedNumber`. `number` is equal to `10`(the value of `num1`). Again, the unary operator `++` _first returns_ the value of the operand, _then increments_ the value of the operand. The value of `number` is `10`, so `num2` is equal to `10`. +`num2` āĻšāϞ `10`, āϝ⧇āĻšā§‡āϤ⧁ āφāĻŽāϰāĻž `num1` āϕ⧇ `increasePassedNumber`-āĻ āĻĒāĻžāϏ āĻ•āϰ⧇āĻ›āĻŋāĨ¤ `number` āϏāĻŽāĻžāύ āĻšāϞ `10` (`num1` āĻāϰ āĻŽāĻžāύ)āĨ¤ āφāĻŦāĻžāϰ, āχāωāύāĻžāϰ⧀ āĻ…āĻĒāĻžāϰ⧇āϟāϰ `++` _āĻĒā§āϰāĻĨāĻŽā§‡ āĻ…āĻĒāĻžāϰ⧇āĻ¨ā§āĻĄā§‡āϰ āĻŽāĻžāύ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇_, āϤāĻžāϰāĻĒāϰ āĻ…āĻĒāĻžāϰ⧇āĻ¨ā§āĻĄā§‡āϰ āĻŽāĻžāύ āĻŦ⧃āĻĻā§āϧāĻŋ āĻ•āϰ⧇āĨ¤ āϤāĻžāχ `number` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻšāϞ `10`, āĻĢāϞ⧇ `num2` āϏāĻŽāĻžāύāĻ“ āĻšā§Ÿ `10`āĨ¤

@@ -2022,13 +2022,13 @@ multiply(value); #### āωāĻ¤ā§āϤāϰ: C -In ES6, we can initialize parameters with a default value. The value of the parameter will be the default value, if no other value has been passed to the function, or if the value of the parameter is `"undefined"`. In this case, we spread the properties of the `value` object into a new object, so `x` has the default value of `{ number: 10 }`. +āχāĻāϏā§Ŧ āĻ, āφāĻŽāϰāĻž āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰāϕ⧇ āĻāĻ•āϟāĻŋ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻ­ā§āϝāĻžāϞ⧁ āĻĻāĻŋā§Ÿā§‡ āχāύāĻŋāĻļāĻŋ⧟āĻžāϞāĻžāχāϜ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋāχ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻšāĻŋāϏ⧇āĻŦ⧇ āĻĨ⧇āϕ⧇ āϝāĻžā§Ÿ āϝāĻĻāĻŋ āύāĻž āĻĢāĻžāĻ‚āĻļāύ⧇ āĻ…āĻ¨ā§āϝ āϕ⧋āύ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāϏ āĻ•āϰāĻž āĻšā§Ÿ, āĻ…āĻĨāĻŦāĻž āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ `"undefined"` āĻšā§ŸāĨ¤ āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āφāĻŽāϰāĻž `value` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϏāϗ⧁āϞ⧋āϕ⧇ āύāϤ⧁āύ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āĻ¸ā§āĻĒā§āϰ⧇āĻĄ āĻ•āϰ⧇āĻ›āĻŋ, āϤāĻžāχ `x`-āĻāϰ āĻ•āĻžāϛ⧇ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻ­ā§āϝāĻžāϞ⧁ āĻĨāĻžāĻ•āϛ⧇ `{ number: 10 }`āĨ¤ -The default argument is evaluated at _call time_! Every time we call the function, a _new_ object is created. We invoke the `multiply` function the first two times without passing a value: `x` has the default value of `{ number: 10 }`. We then log the multiplied value of that number, which is `20`. +āĻĄāĻŋāĻĢāĻ˛ā§āϟ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟāϟāĻŋāϰ āĻŽāĻžāύ āύāĻŋāĻ°ā§āύ⧟ āĻšā§Ÿāϛ⧇ āĻĢāĻžāĻ‚āĻļāύ _āĻ•āϞ⧇āϰ āϏāĻŽā§Ÿ_ ! āφāĻŽāϰāĻž āĻĒā§āϰāϤāĻŋāĻŦāĻžāϰ āĻĢāĻžāĻ‚āĻļāύ āĻ•āϰāĻ›āĻŋ, āĻāĻ•āϟāĻŋ _āύāϤ⧁āύ_ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āϤ⧈āϰāĻŋ āĻšāĻšā§āϛ⧇āĨ¤ āĻĒā§āϰāĻĨāĻŽ āĻĻ⧁āĻŦāĻžāϰ āφāĻŽāϰāĻž āϕ⧋āύ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāϏ āύāĻž āĻ•āϰ⧇āχ `multiply` āĻĢāĻžāĻ‚āĻļāϕ⧇ āϚāĻžāϞāĻŋā§Ÿā§‡āĻ›āĻŋāσ āϤāĻžāχ `x`-āĻāϰ āĻ•āĻžāϛ⧇ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻĨāĻžāĻ•āϛ⧇ `{ number: 10 }`āĨ¤ āϤāĻžāϰāĻĒāϰ āφāĻŽāϰāĻž āϗ⧁āĻŖāĻĢāϞ āϞāĻ— āĻ•āϰ⧇āĻ›āĻŋ, āϝ⧇āϟāĻŋ āĻšā§Ÿ `20`āĨ¤ -The third time we invoke multiply, we do pass an argument: the object called `value`. The `*=` operator is actually shorthand for `x.number = x.number * 2`: we modify the value of `x.number`, and log the multiplied value `20`. +ā§Šā§Ÿ āĻŦāĻžāϰ, `multiply` āĻĢāĻžāĻ‚āĻļāϕ⧇ āϚāĻžāϞāĻŋā§Ÿā§‡āĻ›āĻŋ, āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āĻ `value` āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āĻĒāĻžāϏ āĻ•āϰ⧇āĨ¤ `*=` āĻ…āĻĒāĻžāϰ⧇āϟāϰāϟāĻŋ āφāϏāϞ⧇ `x.number = x.number * 2` āĻāϰ āϏāĻ‚āĻ•ā§āώāĻŋāĻĒā§āϤāϰ⧂āĻĒāσ āφāĻŽāϰāĻž `x.number`-āĻāϰ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇āĻ›āĻŋ āĻāĻŦāĻ‚ āϗ⧁āĻŖāĻĢāϞ `20`-āϕ⧇ āϞāĻ— āĻ•āϰ⧇āĻ›āĻŋāĨ¤ -The fourth time, we pass the `value` object again. `x.number` was previously modified to `20`, so `x.number *= 2` logs `40`. +ā§ĒāĻ°ā§āĻĨ āĻŦāĻžāϰ⧇, āφāĻŽāϰāĻž āφāĻŦāĻžāϰ `value` āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āĻĒāĻžāϏ āĻ•āϰ⧇āĻ›āĻŋāĨ¤ āϝ⧇āĻšā§‡āϤ⧁ āφāϗ⧇āϰāĻŦāĻžāϰ `x.number`-āĻāϰ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇ `20` āĻĒā§‡ā§Ÿā§‡āĻ›āĻŋāϞāĻžāĻŽ, āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āϝ⧇āĻšā§‡āϤ⧁ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āϟāĻžāχāĻĒ āϤāĻžāχ āĻāĻ–āύ `x.number *= 2` āϞāĻ— āĻ•āϰ⧇ `40` āĻĒāĻžāĻšā§āĻ›āĻŋāĨ¤

@@ -2051,17 +2051,17 @@ The fourth time, we pass the `value` object again. `x.number` was previously mod #### āωāĻ¤ā§āϤāϰ: D -The first argument that the `reduce` method receives is the _accumulator_, `x` in this case. The second argument is the _current value_, `y`. With the reduce method, we execute a callback function on every element in the array, which could ultimately result in one single value. +`reduce` āĻŽā§‡āĻĨāĻĄ ā§§āĻŽ āϝ⧇ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟāϟāĻŋ āĻ¨ā§‡ā§Ÿ āϤāĻžāϕ⧇ āĻŦāϞāĻž āĻšā§Ÿ _accumulator_, āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ āϏ⧇āϟāĻž `x`āĨ¤ ⧍⧟ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟāϟāĻŋāϕ⧇ āĻŦāϞāĻž āĻšā§Ÿ _current value_, `y`āĨ¤ `reduce` āĻŽā§‡āĻĨāĻĄā§‡āϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡, āφāĻŽāϰāĻž āĻ…ā§āϝāĻžāϰ⧇āϰ āĻĒā§āϰāϤ⧀āϟāĻŋ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āϜāĻ¨ā§āϝ āĻāĻ•āϟāĻŋ āĻ•āϞāĻŦā§āϝāĻžāĻ• āĻĢāĻžāĻ‚āĻļāύ āϚāĻžāϞāĻžāχ, āϝāĻž āĻļ⧇āώ āĻĒāĻ°ā§āϝāĻ¨ā§āϤ āĻāĻ•āϟāĻŋ āĻāĻ•āĻ• āĻŽāĻžāύ⧇āϰ āĻĢāϞāĻžāĻĢāϞ āĻĒā§āϰāĻĻāĻžāύ āĻ•āϰ⧇āĨ¤ -In this example, we are not returning any values, we are simply logging the values of the accumulator and the current value. +āĻāχ āωāĻĻāĻžāĻšāϰāύ⧇āϰ āĻŦ⧇āϞāĻžā§Ÿ, āφāĻŽāϰāĻž āϕ⧋āύ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇āχ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻ›āĻŋ āύāĻž, āϕ⧇āĻŦāϞ āĻĻ⧁āϟāĻŋ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇ _accumulator_ āĻ“ _current value_ āϞāĻ— āĻ•āϰāĻ›āĻŋ -The value of the accumulator is equal to the previously returned value of the callback function. If you don't pass the optional `initialValue` argument to the `reduce` method, the accumulator is equal to the first element on the first call. +_accumulator_ āĻāϰ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻ•āϞāĻŦā§āϝāĻžāĻ• āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āφāϗ⧇āϰāĻŦāĻžāϰ⧇āϰ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻž āĻ­ā§āϝāĻžāϞ⧁āϰ āϏāĻŽāĻžāύ āĻšā§ŸāĨ¤ `reduce` āĻŽā§‡āĻĨāĻĄā§‡āϰ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āĻŸā§‡ āφāĻĒāύāĻŋ āϝāĻĻāĻŋ āĻ…āĻĒāĻļāύāĻžāϞ āĻ­ā§āϝāĻžāϞ⧁ `initialValue` āĻĒāĻžāϏ āύāĻž āĻ•āϰ⧇āύ, āϤāĻŦ⧇ ā§§āĻŽ āĻ•āϞ⧇āϰ āϏāĻŽā§Ÿ _accumulator_ āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āϏāĻŽāĻžāύ āĻšā§Ÿ āĻ…ā§āϝāĻžāϰ⧇āϰ ā§§āĻŽ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟāϟāĻŋāĨ¤ -On the first call, the accumulator (`x`) is `1`, and the current value (`y`) is `2`. We don't return from the callback function, we log the accumulator, and the current values: `1` and `2` get logged. +ā§§āĻŽ āĻ•āϞ⧇, _accumulator_ (`x`) āĻšā§Ÿ `1` āĻāĻŦāĻ‚ _current value_ (`y`) āĻšā§Ÿ `2`āĨ¤ āφāĻŽāϰāĻž āĻ•āϞāĻŦā§āϝāĻžāĻ• āĻĢāĻžāĻ‚āĻļāύ āĻĨ⧇āϕ⧇ āϕ⧋āύ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇āχ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻ›āĻŋ āύāĻž, āϕ⧇āĻŦāϞ _accumulator_ āĻ“ _current value_ āĻ­ā§āϝāĻžāϞ⧁ āϞāĻ— āĻ•āϰāĻ›āĻŋāσ `1` āĻ“ `2` āϞāĻ— āĻšā§Ÿā§‡āϛ⧇āĨ¤ -If you don't return a value from a function, it returns `undefined`. On the next call, the accumulator is `undefined`, and the current value is `3`. `undefined` and `3` get logged. +āφāĻĒāύāĻŋ āϝāĻĻāĻŋ āĻĢāĻžāĻ‚āĻļāύ āĻĨ⧇āϕ⧇ āĻ•āĻŋāϛ⧁ āϰāĻŋāϟāĻžāĻ°ā§āύ āύāĻž āĻ•āϰ⧇āύ āϤāĻŦ⧇, āĻāϟāĻž `undefined` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤ āϤāĻžāχ āĻĒāϰāĻŦāĻ°ā§āϤāĻŋ āĻ•āϞ⧇, _accumulator_ āĻšā§Ÿ `undefined` _current value_ āĻšā§Ÿ `3`āĨ¤ `undefined` āĻ“ `3` āϞāĻ— āĻšā§Ÿā§‡āϛ⧇āĨ¤ -On the fourth call, we again don't return from the callback function. The accumulator is again `undefined`, and the current value is `4`. `undefined` and `4` get logged. +ā§ĒāĻ°ā§āĻĨ āĻ•āϞ⧇, āφāĻŽāϰāĻž āφāĻŦāĻžāϰāĻ“ āĻ•āϞāĻŦā§āϝāĻžāĻ• āĻĢāĻžāĻ‚āĻļāύ āĻĨ⧇āϕ⧇ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻ›āĻŋ āύāĻžāĨ¤ āϤāĻžāχ _accumulator_ āφāĻŦāĻžāϰāĻ“ āĻšā§Ÿ `undefined`, āĻāĻŦāĻ‚ _current value_ āĻšā§Ÿ `4`āĨ¤ `undefined` āĻ“ `4` āϞāĻ— āĻšā§Ÿā§‡āϛ⧇āĨ¤

From b236c778a5ba9a79d7ea8576a0f556d4357e6361 Mon Sep 17 00:00:00 2001 From: iamsaief Date: Sun, 2 Jun 2024 09:50:34 +0600 Subject: [PATCH 05/12] added translation till 80 --- bn-BD/README_bn-BD.md | 98 ++++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 48 deletions(-) diff --git a/bn-BD/README_bn-BD.md b/bn-BD/README_bn-BD.md index 1f798452..f292c293 100644 --- a/bn-BD/README_bn-BD.md +++ b/bn-BD/README_bn-BD.md @@ -2068,7 +2068,7 @@ _accumulator_ āĻāϰ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻ•āϞāĻŦā§āϝāĻžāĻ• āĻĢāĻžāĻ‚āĻļ --- -###### 66. With which constructor can we successfully extend the `Dog` class? +###### 66. āϕ⧋āύ āĻ•āĻ¨ā§āϏāĻŸā§āϰāĻžāĻ•ā§āϟāϰāϟāĻŋ āĻĻāĻŋā§Ÿā§‡ āφāĻŽāϰāĻž āϏāĻĢāϞāĻ­āĻžāĻŦ⧇ `Dog` āĻ•ā§āϞāĻžāϏāϕ⧇ āĻāĻ•ā§āϏāĻŸā§‡āĻ¨ā§āĻĄ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ? ```javascript class Dog { @@ -2111,11 +2111,11 @@ class Labrador extends Dog { #### āωāĻ¤ā§āϤāϰ: B -In a derived class, you cannot access the `this` keyword before calling `super`. If you try to do that, it will throw a ReferenceError: 1 and 4 would throw a reference error. +āĻāĻ•āϟāĻŋ āĻĄāĻŋāϰāĻžāχāĻ­āĻĄ āĻ•ā§āϞāĻžāϏ⧇, āφāĻĒāύāĻŋ `super` āĻ•āϞ āĻ•āϰāĻžāϰ āφāϗ⧇ `this` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻ…ā§āϝāĻžāĻ•ā§āϏ⧇āϏ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŦ⧇āύ āύāĻžāĨ¤ āφāĻĒāύāĻŋ āϝāĻĻāĻŋ āĻāϟāĻŋ āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰ⧇āύ āϤāĻŦ⧇ āĻāϟāĻŋ āĻāĻ•āϟāĻŋ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āĻāϰāϰ (ReferenceError) āĻĨā§āϰ⧋ āĻ•āϰāĻŦ⧇: 1 āĻāĻŦāĻ‚ 4 āĻāĻ•āϟāĻŋ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āĻāϰāϰ āĻĨā§āϰ⧋ āĻ•āϰāĻŦ⧇āĨ¤ -With the `super` keyword, we call that parent class's constructor with the given arguments. The parent's constructor receives the `name` argument, so we need to pass `name` to `super`. +`super` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĻāĻŋāϝāĻŧ⧇, āφāĻŽāϰāĻž āĻĒā§āϰāĻĻāĻ¤ā§āϤ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āϏāĻš āϏ⧇āχ āĻĒā§āϝāĻžāϰ⧇āĻ¨ā§āϟ āĻ•ā§āϞāĻžāϏ⧇āϰ āĻ•āύāĻ¸ā§āĻŸā§āϰāĻžāĻ•ā§āϟāϰāϕ⧇ āĻ•āϞ āĻ•āϰāĻŋāĨ¤ āĻĒā§āϝāĻžāϰ⧇āĻ¨ā§āĻŸā§‡āϰ āĻ•āĻ¨ā§āϏāĻŸā§āϰāĻžāĻ•ā§āϟāϰ `name` āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āĻ¨ā§‡ā§Ÿ, āϤāĻžāχ `super`-āĻ āφāĻŽāĻžāĻĻ⧇āϰ `name` āĻĒāĻžāϏ āĻ•āϰāϤ⧇ āĻšāĻŦ⧇āĨ¤ -The `Labrador` class receives two arguments, `name` since it extends `Dog`, and `size` as an extra property on the `Labrador` class. They both need to be passed to the constructor function on `Labrador`, which is done correctly using constructor 2. +`Labrador` āĻ•ā§āϞāĻžāϏ āĻĻ⧁āϟāĻŋ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āĻ¨ā§‡ā§Ÿ, `name` āϝ⧇āĻšā§‡āϤ⧁ āĻāϟāĻŋ `Dog` āĻ•ā§āϞāĻžāϏāϕ⧇ āĻāĻ•ā§āϏāĻŸā§‡āĻ¨ā§āĻĄ āĻ•āϰ⧇ āĻāĻŦāĻ‚ `size` āϕ⧇ `Labrador` āĻ•ā§āϞāĻžāϏ⧇ āĻāĻ•āϟāĻŋ āĻ…āϤāĻŋāϰāĻŋāĻ•ā§āϤ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āĻšāĻŋāϏāĻžāĻŦ⧇ āĻāĻ•ā§āϏāĻŸā§‡āĻ¨ā§āĻĄ āĻ•āϰ⧇āĨ¤ āϤāĻžāĻĻ⧇āϰ āωāĻ­āϝāĻŧāϕ⧇āχ `Labrador`-āĻāϰ āĻ•āύāĻ¸ā§āĻŸā§āϰāĻžāĻ•ā§āϟāϰ āĻĢāĻžāĻ‚āĻļāύ⧇ āĻĒāĻžāϏ āĻ•āϰāϤ⧇ āĻšāĻŦ⧇, āϝāĻž āĻ•āύāĻ¸ā§āĻŸā§āϰāĻžāĻ•ā§āϟāϰ 2 āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ āϏāĻ āĻŋāĻ•āĻ­āĻžāĻŦ⧇ āĻ•āϰāĻž āĻšāϝāĻŧ⧇āϛ⧇āĨ¤

@@ -2145,9 +2145,9 @@ export const sum = (a, b) => a + b; #### āωāĻ¤ā§āϤāϰ: B -With the `import` keyword, all imported modules are _pre-parsed_. This means that the imported modules get run _first_, and the code in the file that imports the module gets executed _after_. +`import` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻŦā§āϝāĻŦāĻšā§ƒāϤ āĻšāϞ⧇, `import` āĻ•āϰāĻž āϏāĻŽāĻ¸ā§āϤ āĻŽāĻĄāĻŋāωāϞ _āĻĒā§āϰāĻŋ-āĻĒāĻžāĻ°ā§āϏ_ āĻ•āϰāĻž āĻšāϝāĻŧāĨ¤ āĻāϰ āĻŽāĻžāύ⧇ āĻšāϞ āϝ⧇ āχāĻŽā§āĻĒā§‹āĻ°ā§āϟ āĻ•āϰāĻž āĻŽāĻĄāĻŋāωāϞāϗ⧁āϞāĻŋ _āĻĒā§āϰāĻĨāĻŽā§‡_ āϚāĻžāϞāĻžāύ⧋ āĻšāϝāĻŧ, āĻāĻŦāĻ‚ āϝ⧇ āĻĢāĻžāχāϞ⧇ āĻŽāĻĄāĻŋāωāϞāϟāĻŋ āχāĻŽā§āĻĒā§‹āĻ°ā§āϟ āĻ•āϰāĻž āĻšā§Ÿ āϤāĻžāϰ āϕ⧋āĻĄ _āĻĒāϰāĻŦāĻ°ā§āϤ⧀āϤ⧇_ āϚāϞāĻŦ⧇āĨ¤ -This is a difference between `require()` in CommonJS and `import`! With `require()`, you can load dependencies on demand while the code is being run. If we had used `require` instead of `import`, `running index.js`, `running sum.js`, `3` would have been logged to the console. +āĻāϟāĻŋ CommonJS-āĻ `require()` āĻāĻŦāĻ‚ `import` āĻāϰ āĻŽāĻ§ā§āϝ⧇ āĻāĻ•āϟāĻŋ āĻĒāĻžāĻ°ā§āĻĨāĻ•ā§āϝ! `require()` āĻĻāĻŋāϝāĻŧ⧇, āϕ⧋āĻĄ āϚāĻžāϞāĻžāύ⧋āϰ āϏāĻŽāϝāĻŧ āφāĻĒāύāĻŋ āĻĒā§āĻ°ā§Ÿā§‹āϜāύ āĻ…āύ⧁āϝāĻžā§Ÿā§€ āĻĄāĻŋāĻĒ⧇āĻ¨ā§āĻĄā§‡āĻ¨ā§āϏāĻŋāϗ⧁āϞ⧋ āϞ⧋āĻĄ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āύāĨ¤ āφāĻŽāϰāĻž āϝāĻĻāĻŋ `import` āĻāϰ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤ⧇ `require` āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāϤāĻžāĻŽ, āĻ•āύāϏ⧋āϞ⧇ āϞāĻ— āĻšāϤ⧋āσ `running index.js`, `running sum.js`, `3`āĨ¤

@@ -2172,7 +2172,7 @@ console.log(Symbol('foo') === Symbol('foo')); #### āωāĻ¤ā§āϤāϰ: A -Every Symbol is entirely unique. The purpose of the argument passed to the Symbol is to give the Symbol a description. The value of the Symbol is not dependent on the passed argument. As we test equality, we are creating two entirely new symbols: the first `Symbol('foo')`, and the second `Symbol('foo')`. These two values are unique and not equal to each other, `Symbol('foo') === Symbol('foo')` returns `false`. +āĻĒā§āϰāϤāĻŋāϟāĻŋ Symbol āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖ āĻ…āύāĻ¨ā§āϝāĨ¤ Symbol-āĻ āĻĒāĻžāϏ āĻ•āϰāĻž āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟāϟāĻŋāϰ āωāĻĻā§āĻĻ⧇āĻļā§āϝ āĻšāϞ Symbol-āϟāĻŋāϕ⧇ āĻāĻ•āϟāĻŋ āĻŦāĻ°ā§āĻŖāύāĻž āĻĻ⧇āĻ“āϝāĻŧāĻžāĨ¤ Symbol-āĻāϰ āĻŽāĻžāύ āĻĒāĻžāϏ āĻ•āϰāĻž āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āωāĻĒāϰ āύāĻŋāĻ°ā§āĻ­āϰ āĻ•āϰ⧇ āύāĻžāĨ¤ āφāĻŽāϰāĻž āϏāĻŽāϤāĻž āĻĒāϰ⧀āĻ•ā§āώāĻž āĻ•āϰāĻžāϰ āϏāĻŽāϝāĻŧ, āφāĻŽāϰāĻž āĻĻ⧁āϟāĻŋ āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖ āύāϤ⧁āύ Symbol āϤ⧈āϰāĻŋ āĻ•āϰāĻ›āĻŋ: āĻĒā§āϰāĻĨāĻŽ `Symbol('foo')`, āĻāĻŦāĻ‚ āĻĻā§āĻŦāĻŋāϤ⧀āϝāĻŧ `Symbol('foo')`āĨ¤ āĻāχ āĻĻ⧁āϟāĻŋ āĻŽāĻžāύ āĻ…āύāĻ¨ā§āϝ āĻāĻŦāĻ‚ āĻāϕ⧇ āĻ…āĻĒāϰ⧇āϰ āϏāĻŽāĻžāύ āύāϝāĻŧ, āϤāĻžāχ `Symbol('foo') === Symbol('foo')` `false` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤

@@ -2197,9 +2197,9 @@ console.log(name.padStart(2)); #### āωāĻ¤ā§āϤāϰ: C -With the `padStart` method, we can add padding to the beginning of a string. The value passed to this method is the _total_ length of the string together with the padding. The string `"Lydia Hallie"` has a length of `12`. `name.padStart(13)` inserts 1 space at the start of the string, because 12 + 1 is 13. +`padStart` āĻĒāĻĻā§āϧāϤāĻŋāϰ āϏāĻžāĻšāĻžāĻ¯ā§āϝ⧇, āφāĻŽāϰāĻž āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āϝāĻŧ⧇āϰ āĻļ⧁āϰ⧁āϤ⧇ āĻĒā§āϝāĻžāĻĄāĻŋāĻ‚ (āĻļā§‚āĻ¨ā§āϝāĻ¸ā§āĻĨāĻžāύ) āϝ⧋āĻ— āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ āĻāχ āĻĒāĻĻā§āϧāϤāĻŋāϤ⧇ āĻĒāĻžāϏ āĻ•āϰāĻž āĻŽāĻžāύ āĻšāϞ āĻĒā§āϝāĻžāĻĄāĻŋāĻ‚āϝāĻŧ⧇āϰ āϏāĻžāĻĨ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āϝāĻŧ⧇āϰ _āĻŽā§‹āϟ_ āĻĻ⧈āĻ°ā§āĻ˜ā§āϝāĨ¤ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ `"Lydia Hallie"` āĻāϰ āĻĻ⧈āĻ°ā§āĻ˜ā§āϝ `12`āĨ¤ `name.padStart(13)` āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻāϰ āĻļ⧁āϰ⧁āϤ⧇ 1āϟāĻŋ āĻļā§‚āĻ¨ā§āϝāĻ¸ā§āĻĨāĻžāύ āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻžāϰ āĻ•āĻžāϰāύ⧇ _āĻŽā§‹āϟ_ āĻĻ⧈āĻ°ā§āĻ˜ā§āϝ 12 + 1 āĻ…āĻ°ā§āĻĨāĻžā§Ž 13 āĻšā§ŸāĨ¤ -If the argument passed to the `padStart` method is smaller than the length of the array, no padding will be added. +āϝāĻĻāĻŋ `padStart` āĻĒāĻĻā§āϧāϤāĻŋāϤ⧇ āĻĒāĻžāϏ āĻ•āϰāĻž āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚-āĻāϰ āĻĻ⧈āĻ°ā§āĻ˜ā§āϝ⧇āϰ āĻšā§‡āϝāĻŧ⧇ āϛ⧋āϟ āĻšāϝāĻŧ, āϤāĻžāĻšāϞ⧇ āϕ⧋āύ⧋ āĻĒā§āϝāĻžāĻĄāĻŋāĻ‚ āϝ⧋āĻ— āĻ•āϰāĻž āĻšāĻŦ⧇ āύāĻžāĨ¤

@@ -2222,19 +2222,19 @@ console.log('đŸĨ‘' + 'đŸ’ģ'); #### āωāĻ¤ā§āϤāϰ: A -With the `+` operator, you can concatenate strings. In this case, we are concatenating the string `"đŸĨ‘"` with the string `"đŸ’ģ"`, resulting in `"đŸĨ‘đŸ’ģ"`. +`+` āĻ…āĻĒāĻžāϰ⧇āϟāϰ āĻĻāĻŋā§Ÿā§‡, āφāĻĒāύāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āϝ⧁āĻ•ā§āϤ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āύāĨ¤ āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āφāĻŽāϰāĻž āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ `"đŸĨ‘"` āϕ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ `"đŸ’ģ"` -āĻāϰ āϏāĻžāĻĨ⧇ āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻ›āĻŋ, āϝāĻžāϰ āĻĢāϞāĻžāĻĢāϞ `"đŸĨ‘đŸ’ģ"`āĨ¤

--- -###### 71. How can we log the values that are commented out after the console.log statement? +###### 71. `console.log` āĻ¸ā§āĻŸā§āϝāĻžāϟāĻŽā§āϝāĻžāĻ¨ā§āϟ āĻāϰ āĻĒāϰ⧇ āĻ•āĻŽā§‡āĻ¨ā§āϟ āĻ•āϰāĻž āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋāϕ⧇ āφāĻŽāϰāĻž āĻ•āĻŋāĻ­āĻžāĻŦ⧇ āϞāĻ— āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ? ```javascript function* startGame() { - const āωāĻ¤ā§āϤāϰ = yield 'Do you love JavaScript?'; - if (āωāĻ¤ā§āϤāϰ !== 'Yes') { + const answer = yield 'Do you love JavaScript?'; + if (answer !== 'Yes') { return "Oh wow... Guess we're done here"; } return 'JavaScript loves you back â¤ī¸'; @@ -2255,11 +2255,11 @@ console.log(/* 2 */); // JavaScript loves you back â¤ī¸ #### āωāĻ¤ā§āϤāϰ: C -A generator function "pauses" its execution when it sees the `yield` keyword. First, we have to let the function yield the string "Do you love JavaScript?", which can be done by calling `game.next().value`. +āĻāĻ•āϟāĻŋ āĻœā§‡āύāĻžāϰ⧇āϟāϰ āĻĢāĻžāĻ‚āĻļāύ āϝāĻ–āύ `yield` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄāϟāĻŋ āĻĻ⧇āϖ⧇ āϤāĻ–āύ āϤāĻžāϰ āϚāϞāĻŽāĻžāύ āĻ…āĻŦāĻ¸ā§āĻĨāĻžā§Ÿ "āĻŦāĻŋāϰāϤāĻŋ āĻĻ⧇āϝāĻŧ" ("pauses" execution)āĨ¤ āĻĒā§āϰāĻĨāĻŽāϤ, āφāĻŽāĻžāĻĻ⧇āϰ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻĨ⧇āϕ⧇ "Do you love JavaScript?" āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āϟāĻŋ āĻĒ⧇āϤ⧇ āĻšāĻŦ⧇, āϝāĻž `game.next().value` āĻ•āϞ āĻ•āϰ⧇ āĻĒāĻžāĻ“ā§ŸāĻž āϝāĻžāĻŦ⧇āĨ¤ -Every line is executed, until it finds the first `yield` keyword. There is a `yield` keyword on the first line within the function: the execution stops with the first yield! _This means that the variable `āωāĻ¤ā§āϤāϰ` is not defined yet!_ +āĻĒā§āϰāϤāĻŋāϟāĻŋ āϞāĻžāχāύ āϚāĻžāϞāύāĻž āĻ•āϰāĻž āĻšāϝāĻŧ, āϝāϤāĻ•ā§āώāĻŖ āύāĻž āĻāϟāĻŋ āĻĒā§āϰāĻĨāĻŽ `yield` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āϖ⧁āρāĻœā§‡ āĻĒāĻžāϝāĻŧāĨ¤ āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āĻŽāĻ§ā§āϝ⧇ āĻĒā§āϰāĻĨāĻŽ āϞāĻžāχāύ⧇ āĻāĻ•āϟāĻŋ `yield` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āφāϛ⧇: āĻĒā§āϰāĻĨāĻŽ āĻĢāϞāĻžāĻĢāϞ⧇āϰ (yield) āϏāĻžāĻĨ⧇āχ āĻāĻ•ā§āϏāĻŋāĻ•āĻŋāωāĻļāύ āĻŦāĻ¨ā§āϧ āĻšāϝāĻŧ⧇ āϝāĻžāϝāĻŧ! _āĻāϰ āĻŽāĻžāύ⧇ āĻšāϞ `answer` āϭ⧇āϰāĻŋāϝāĻŧ⧇āĻŦāϞ āĻāĻ–āύ⧋ āĻĄāĻŋāĻĢāĻžāχāύ āĻ•āϰāĻž āĻšāϝāĻŧāύāĻŋ!_ -When we call `game.next("Yes").value`, the previous `yield` is replaced with the value of the parameters passed to the `next()` function, `"Yes"` in this case. The value of the variable `āωāĻ¤ā§āϤāϰ` is now equal to `"Yes"`. The condition of the if-statement returns `false`, and `JavaScript loves you back â¤ī¸` gets logged. +āϝāĻ–āύ āφāĻŽāϰāĻž `game.next("Yes").value` āĻ•āϞ āĻ•āϰāĻŋ, āϤāĻ–āύ āφāϗ⧇āϰ `yield`āϟāĻŋāϕ⧇ `next()` āĻĢāĻžāĻ‚āĻļāύ⧇ āĻĒāĻžāϏ āĻ•āϰāĻž āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ⧇āϰ āĻŽāĻžāύ āĻĻāĻŋāϝāĻŧ⧇ āĻĒā§āϰāϤāĻŋāĻ¸ā§āĻĨāĻžāĻĒāĻŋāϤ āĻ•āϰāĻž āĻšāϝāĻŧ, āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ `"Yes"` āĻĻāĻŋā§Ÿā§‡āĨ¤ āϭ⧇āϰāĻŋāϝāĻŧ⧇āĻŦāϞ `answer` āĻāϰ āĻŽāĻžāύ āĻāĻ–āύ `"Yes"` āĻāϰ āϏāĻŽāĻžāύāĨ¤ āχāĻĢ-āĻ¸ā§āĻŸā§āϝāĻžāϟāĻŽā§āϝāĻžāĻ¨ā§āĻŸā§‡āϰ āĻļāĻ°ā§āϤ `false` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ āĻāĻŦāĻ‚ `JavaScript loves you back â¤ī¸` āϞāĻ— āĻšāϝāĻŧ⧇ āϝāĻžāϝāĻŧāĨ¤

@@ -2282,19 +2282,19 @@ console.log(String.raw`Hello\nworld`); #### āωāĻ¤ā§āϤāϰ: C -`String.raw` returns a string where the escapes (`\n`, `\v`, `\t` etc.) are ignored! Backslashes can be an issue since you could end up with something like: +`String.raw` āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ āϝ⧇āĻ–āĻžāύ⧇ āĻāĻ¸ā§āϕ⧇āĻĒ āĻ•ā§āϝāĻžāϰ⧇āĻ•ā§āϟāĻžāϰ (`\n`, `\v`, `\t` āχāĻ¤ā§āϝāĻžāĻĻāĻŋ) āωāĻĒ⧇āĻ•ā§āώāĻž āĻ•āϰāĻž āĻšāϝāĻŧ! āĻŦā§āϝāĻžāĻ•āĻ¸ā§āĻ˛ā§āϝāĻžāĻļāϗ⧁āϞāĻŋ āĻāĻ•āϟāĻŋ āϏāĻŽāĻ¸ā§āϝāĻž āĻšāϤ⧇ āĻĒāĻžāϰ⧇ āϝāĻ–āύ āφāĻĒāύāĻŋ āĻāĻŽāύ āĻ•āĻŋāϛ⧁ āĻĒāĻžāĻŦ⧇āύ: `` const path = `C:\Documents\Projects\table.html` `` -Which would result in: +āϝāĻžāϰ āĻĢāϞ⧇ āφāωāϟāĻĒ⧁āϟ āĻšāĻŦ⧇: `"C:DocumentsProjects able.html"` -With `String.raw`, it would simply ignore the escape and print: +`String.raw` āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāϞ⧇, āĻāϟāĻŋ āϕ⧇āĻŦāϞ āĻāĻ¸ā§āϕ⧇āĻĒ āĻ•ā§āϝāĻžāϰ⧇āĻ•ā§āϟāĻžāϰ āωāĻĒ⧇āĻ•ā§āώāĻž āĻ•āϰāĻŦ⧇ āĻāĻŦāĻ‚ āĻĒā§āϰāĻŋāĻ¨ā§āϟ āĻ•āϰāĻŦ⧇: `C:\Documents\Projects\table.html` -In this case, the string is `Hello\nworld`, which gets logged. +āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āϞāĻ— āĻšāĻ“ā§ŸāĻž āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āϟāĻŋ āĻšāϞ `Hello\nworld`āĨ¤

@@ -2322,13 +2322,13 @@ console.log(data); #### āωāĻ¤ā§āϤāϰ: C -An async function always returns a promise. The `await` still has to wait for the promise to resolve: a pending promise gets returned when we call `getData()` in order to set `data` equal to it. +āĻāĻ•āϟāĻŋ **async** āĻĢāĻžāĻ‚āĻļāύ āϏāĻ°ā§āĻŦāĻĻāĻž āĻāĻ•āϟāĻŋ āĻĒā§āϰāϤāĻŋāĻļā§āϰ⧁āϤāĻŋ (promise) āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤ āĻĒā§āϰāĻŽāĻŋāϏ āϏāĻŽāĻžāϧāĻžāύ⧇āϰ (resolve) āϜāĻ¨ā§āϝ `await`āϕ⧇ āĻāĻ–āύāĻ“ āĻ…āĻĒ⧇āĻ•ā§āώāĻž āĻ•āϰāϤ⧇ āĻšāĻšā§āϛ⧇: āϝāĻ–āύ `getData()` āĻ•āϞ āĻ•āϰ⧇ āĻāϟāĻŋāϰ āĻŽāĻžāύāϕ⧇ `data`-āϰ āϏāĻŽāĻžāύ āϏ⧇āϟ āĻ•āϰāĻž āĻšā§Ÿ āϤāĻ–āύ āφāϏāϞ⧇ āĻāĻ•āϟāĻŋ āĻ…āĻŽā§€āĻŽāĻžāĻ‚āϏāĻŋāϤ (pending) āĻĒā§āϰāĻŽāĻŋāϏ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ­ā§āϝāĻžāϞ⧁ āĻšāĻŋāϏ⧇āĻŦ⧇ āĻĒāĻžāĻ“ā§ŸāĻž āϝāĻžā§ŸāĨ¤ -If we wanted to get access to the resolved value `"I made it"`, we could have used the `.then()` method on `data`: +āϝāĻĻāĻŋ āφāĻŽāϰāĻž āĻĒā§āϰāĻŽāĻŋāϏ āϏāĻŽāĻžāϧāĻžāύ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁āϰ - `"I made it"` āĻ…ā§āϝāĻžāĻ•ā§āϏ⧇āϏ āĻĒ⧇āϤ⧇ āϚāĻžāχāϤāĻžāĻŽ, āϤāĻžāĻšāϞ⧇ `data`-āϤ⧇ `.then()` āĻŽā§‡āĻĨāĻĄ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāϤ⧇ āĻšāϤ: `data.then(res => console.log(res))` -This would've logged `"I made it!"` +āϤāĻŦ⧇āχ āĻāϟāĻŋ āϞāĻ— āĻ•āϰāϤ `"I made it!"`⧎

@@ -2356,9 +2356,9 @@ console.log(result); #### āωāĻ¤ā§āϤāϰ: B -The `.push()` method returns the _length_ of the new array! Previously, the array contained one element (the string `"banana"`) and had a length of `1`. After adding the string `"apple"` to the array, the array contains two elements, and has a length of `2`. This gets returned from the `addToList` function. +`.push()` āĻŽā§‡āĻĨāĻĄ āύāϤ⧁āύ āĻ…ā§āϝāĻžāϰ⧇āϰ _length_ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇! āĻĒā§‚āĻ°ā§āĻŦ⧇, āĻ…ā§āϝāĻžāϰ⧇āϤ⧇ āĻāĻ•āϟāĻŋ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟ āĻ›āĻŋāϞ (āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ `"banana"`) āĻāĻŦāĻ‚ āĻāϰ āĻĻ⧈āĻ°ā§āĻ˜ā§āϝ āĻ›āĻŋāϞ `1`āĨ¤ āĻ…ā§āϝāĻžāϰ⧇āϤ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ `"apple"` āϝ⧋āĻ— āĻ•āϰāĻžāϰ āĻĒāϰ, āĻ…ā§āϝāĻžāϰ⧇āϰ āĻŽā§‹āϟ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟ āĻšā§Ÿ āĻĻ⧁āϟāĻŋ āĻāĻŦāĻ‚ āĻāϰ āĻĻ⧈āĻ°ā§āĻ˜ā§āϝ āĻšā§Ÿ `2`āĨ¤ āĻāϟāĻŋāχ 'addToList' āĻĢāĻžāĻ‚āĻļāύ āĻĨ⧇āϕ⧇ āϰāĻŋāϟāĻžāĻ°ā§āύ āφāϏāϛ⧇āĨ¤ -The `push` method modifies the original array. If you wanted to return the _array_ from the function rather than the _length of the array_, you should have returned `list` after pushing `item` to it. +`push` āĻŽā§‡āĻĨāĻĄāϟāĻŋ āĻŽā§‚āϞ āĻ…ā§āϝāĻžāϰ⧇āϕ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇āĨ¤ āφāĻĒāύāĻŋ āϝāĻĻāĻŋ _āĻ…ā§āϝāĻžāϰ⧇āϰ āĻĻ⧈āĻ°ā§āĻ˜ā§āϝ⧇_-āϰ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤ⧇ āĻĢāĻžāĻ‚āĻļāύ āĻĨ⧇āϕ⧇ _array_-āϟāĻŋ āϰāĻŋāϟāĻžāĻ°ā§āύ āϚāĻžāχāϤ⧇āύ, āϤāĻžāĻšāϞ⧇ `item`-āϕ⧇ āĻĒ⧁āĻļ āĻ•āϰāĻžāϰ āĻĒāϰ⧇ āφāĻĒāύāĻžāϰ āωāϚāĻŋāϤ āĻ›āĻŋāϞ `list`-āϕ⧇ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻžāĨ¤

@@ -2388,11 +2388,11 @@ console.log(shape); #### āωāĻ¤ā§āϤāϰ: B -`Object.freeze` makes it impossible to add, remove, or modify properties of an object (unless the property's value is another object). +`Object.freeze` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āϕ⧋āύ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āϝ⧋āĻ—, āĻŦāĻžāĻĻ āĻŦāĻž āϏāĻ‚āĻļā§‹āϧāύ āĻ•āϰāĻž āĻ…āϏāĻŽā§āĻ­āĻŦ āĻ•āϰ⧇ āϤ⧋āϞ⧇ (āϝāĻĻāĻŋ āύāĻž āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϰ āĻŽāĻžāύ āĻ…āĻ¨ā§āϝ āϕ⧋āύ⧋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻšāϝāĻŧ)āĨ¤ -When we create the variable `shape` and set it equal to the frozen object `box`, `shape` also refers to a frozen object. You can check whether an object is frozen by using `Object.isFrozen`. In this case, `Object.isFrozen(shape)` would return true, since the variable `shape` has a reference to a frozen object. +āϝāĻ–āύ āφāĻŽāϰāĻž āϭ⧇āϰāĻŋāϝāĻŧ⧇āĻŦāϞ `shape` āϤ⧈āϰāĻŋ āĻ•āϰāĻŋ āĻāĻŦāĻ‚ āϤāĻžāϕ⧇ āĻĢā§āϰ⧋āĻœā§‡āύ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ `box` āĻāϰ āϏāĻŽāĻžāύ āϏ⧇āϟ āĻ•āϰāĻŋ, `shape`-āĻ“ āϏ⧇āχ āĻĢā§āϰ⧋āĻœā§‡āύ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āϰ⧇āĻĢāĻžāϰ āĻ•āϰ⧇āĨ¤ āφāĻĒāύāĻŋ `Object.isFrozen` āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ āϕ⧋āύ⧋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻĢā§āϰ⧋āĻœā§‡āύ āĻšāϝāĻŧ⧇āϛ⧇ āĻ•āĻŋāύāĻž āϤāĻž āĻĒāϰ⧀āĻ•ā§āώāĻž āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āύāĨ¤ āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, `Object.isFrozen(shape)` true āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻŦ⧇, āĻ•āĻžāϰāύ āϭ⧇āϰāĻŋāϝāĻŧ⧇āĻŦāϞ `shape`-āĻāϰ āĻ•āĻžāϛ⧇ āĻāĻ•āϟāĻŋ āĻĢā§āϰ⧋āĻœā§‡āύ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āφāϛ⧇āĨ¤ -Since `shape` is frozen, and since the value of `x` is not an object, we cannot modify the property `x`. `x` is still equal to `10`, and `{ x: 10, y: 20 }` gets logged. +āϝ⧇āĻšā§‡āϤ⧁ `shape` āĻĢā§āϰ⧋āĻœā§‡āύ āĻšā§Ÿā§‡āϛ⧇, āĻāĻŦāĻ‚ `x` āĻāϰ āĻŽāĻžāύ āϕ⧋āύ⧋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āύāϝāĻŧ, āϤāĻžāχ āφāĻŽāϰāĻž `x` āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϕ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ āύāĻžāĨ¤ `x` āĻāĻ–āύāĻ“ `10` āĻāϰ āϏāĻŽāĻžāύ, āĻāĻŦāĻ‚ `{ x: 10, y: 20 }` āϞāĻ— āĻ•āϰāĻž āĻšāϝāĻŧ⧇āϛ⧇āĨ¤

@@ -2417,7 +2417,7 @@ console.log(firstName); #### āωāĻ¤ā§āϤāϰ: D -By using [destructuring assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) syntax we can unpack values from arrays, or properties from objects, into distinct variables: +[āĻĄāĻŋāĻ¸ā§āĻŸā§āϰāĻžāĻ•āϚāĻžāϰāĻŋāĻ‚ āĻ…ā§āϝāĻžāϏāĻžāχāύāĻŽā§‡āĻ¨ā§āϟ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) āϏāĻŋāύāĻŸā§āϝāĻžāĻ•ā§āϏ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇, āφāĻŽāϰāĻž āĻ…ā§āϝāĻžāϰ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁, āĻŦāĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āĻŦ⧇āϰ āĻ•āϰ⧇ āφāϞāĻžāĻĻāĻž āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞ⧇ āϰāĻžāĻ–āϤ⧇ āĻĒāĻžāϰāĻŋāσ ```javascript const { firstName } = { firstName: 'Lydia' }; @@ -2427,7 +2427,7 @@ const { firstName } = { firstName: 'Lydia' }; console.log(firstName); // "Lydia" ``` -Also, a property can be unpacked from an object and assigned to a variable with a different name than the object property: +āφāĻŦāĻžāϰ, āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻĨ⧇āϕ⧇ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āĻŦ⧇āϰ āĻ•āϰ⧇ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϐ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϰ āύāĻžāĻŽā§‡ āύāĻž āϰ⧇āϖ⧇ āĻ…āĻ¨ā§āϝ āύāĻžāĻŽā§‡āϰ āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞ⧇āĻ“ āϰāĻžāĻ–āϤ⧇ āĻĒāĻžāϰāĻŋāσ ```javascript const { firstName: myName } = { firstName: 'Lydia' }; @@ -2438,9 +2438,9 @@ console.log(myName); // "Lydia" console.log(firstName); // Uncaught ReferenceError: firstName is not defined ``` -Therefore, `firstName` does not exist as a variable, thus attempting to access its value will raise a `ReferenceError`. +āĻ…āϤāĻāĻŦ, `firstName` āĻāĻ•āϟāĻŋ āϭ⧇āϰāĻŋāϝāĻŧ⧇āĻŦāϞ āĻšāĻŋāϏ⧇āĻŦ⧇ āφāϰ āύ⧇āχ, āĻāχāĻ­āĻžāĻŦ⧇ āĻāϰ āĻŽāĻžāύ āĻ…ā§āϝāĻžāĻ•ā§āϏ⧇āϏ āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāϞ⧇ `ReferenceError` āϤ⧈āϰāĻŋ āĻšāĻŦ⧇āĨ¤ -**Note:** Be aware of the `global scope` properties: +**āĻĻā§āϰāĻˇā§āϟāĻŦā§āϝ:** `āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ¸ā§āϕ⧋āĻĒ` āĻŦ⧈āĻļāĻŋāĻˇā§āĻŸā§āϝ āϏāĻŽā§āĻĒāĻ°ā§āϕ⧇ āϏāĻšā§‡āϤāύ āĻĨāĻžāϕ⧁āύ: ```javascript const { name: myName } = { name: 'Lydia' }; @@ -2450,18 +2450,18 @@ console.log(name); // "" ----- Browser e.g. Chrome console.log(name); // ReferenceError: name is not defined ----- NodeJS ``` -Whenever Javascript is unable to find a variable within the _current scope_, it climbs up the [Scope chain](https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch3.md) and searches for it and if it reaches the top-level scope, aka **Global scope**, and still doesn't find it, it will throw a `ReferenceError`. +āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āϝāĻ–āύāχ āĻāĻ•āϟāĻŋ āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞāϕ⧇ āϤāĻžāϰ _āĻŦāĻ°ā§āϤāĻŽāĻžāύ āĻ¸ā§āϕ⧋āĻĒ⧇_ āϖ⧁āρāĻœā§‡ āĻĒāĻžā§Ÿ āύāĻž, āϤāĻ–āύ āĻāϟāĻŋāϕ⧇ āϖ⧁āρāĻœā§‡ āĻĒāĻžāĻ“ā§ŸāĻžāϰ āϜāĻ¨ā§āϝ [āĻ¸ā§āϕ⧋āĻĒ āĻšā§‡āχāύ](https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch3.md)-āĻāϰ āωāĻĒāϰ⧇ āĻ“āϠ⧇ āĻāĻŦāĻ‚ āϝāĻĻāĻŋ āĻāϟāĻŋ āĻļā§€āĻ°ā§āώ-āĻ¸ā§āϤāϰ⧇āϰ āĻ¸ā§āϕ⧋āĻĒ⧇ āĻĒ⧌āρāĻ›āĻžāϝāĻŧ, āĻ“āϰāĻĢ⧇ **āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ¸ā§āϕ⧋āĻĒ**, āĻāĻŦāĻ‚ āĻāĻ–āĻžāύ⧇āĻ“ āϖ⧁āρāĻœā§‡ āύāĻž āĻĒāĻžāϝāĻŧ, āϤāĻžāĻšāϞ⧇ āĻāϟāĻŋ āĻāĻ•āϟāĻŋ `ReferenceError` āĻĨā§āϰ⧋ āĻ•āϰāĻŦ⧇āĨ¤ -- In **Browsers** such as _Chrome_, `name` is a _deprecated global scope property_. In this example, the code is running inside _global scope_ and there is no user-defined local variable for `name`, therefore it searches the predefined _variables/properties_ in the global scope which is in the case of browsers, it searches through `window` object and it will extract the [window.name](https://developer.mozilla.org/en-US/docs/Web/API/Window/name) value which is equal to an **empty string**. +- **āĻŦā§āϰāĻžāωāϜāĻžāϰ⧇** āϝ⧇āĻŽāύ _Chrome_, `name` āĻšāϞ āĻāĻ•āϟāĻŋ _āĻĄā§‡āĻĒā§āϰāĻŋāϕ⧇āĻŸā§‡āĻĄ āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ¸ā§āϕ⧋āĻĒ āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋ_āĨ¤ āĻāχ āωāĻĻāĻžāĻšāϰāύ⧇, āϕ⧋āĻĄāϟāĻŋ _global scope_ āĻāϰ āĻ­āĻŋāϤāϰ⧇ āϚāϞāϛ⧇ āĻāĻŦāĻ‚ `name` āĻāϰ āϜāĻ¨ā§āϝ āϕ⧋āύ⧋ āχāωāϜāĻžāϰ-āĻĄāĻŋāĻĢāĻžāχāĻ¨ā§āĻĄ āϞ⧋āĻ•āĻžāϞ āϭ⧇āϰāĻŋāϝāĻŧ⧇āĻŦāϞ āύ⧇āχ, āϤāĻžāχ āĻāϟāĻŋ āĻĒā§‚āĻ°ā§āĻŦāύāĻŋāĻ°ā§āϧāĻžāϰāĻŋāϤ _āϭ⧇āϰāĻŋāϝāĻŧ⧇āĻŦāϞ/āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ_ āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ¸ā§āϕ⧋āĻĒ⧇ āϖ⧁āρāĻœā§‡ āĻĻ⧇āϖ⧇ āϝāĻž āĻŦā§āϰāĻžāωāϜāĻžāϰ⧇āϰ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, `window` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϭ⧇āϤāϰ⧇ āϖ⧁āρāϜāĻŦ⧇ āĻāĻŦāĻ‚ āĻāϟāĻŋ [window.name](https://developer.mozilla.org/en-US/docs/Web/API/Window/name) āĻŽāĻžāύāϟāĻŋ āĻŦ⧇āϰ āĻ•āϰāĻŦ⧇ āĻāĻ•āϟāĻŋ **āĻ–āĻžāϞāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚** āĻāϰ āϏāĻŽāĻžāύāĨ¤ -- In **NodeJS**, there is no such property on the `global` object, thus attempting to access a non-existent variable will raise a [ReferenceError](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_defined). +- **āύ⧋āĻĄāĻœā§‡āĻāϏ**-āĻ, `āĻ—ā§āϞ⧋āĻŦāĻžāϞ` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āĻāĻŽāύ āϕ⧋āύ⧋ āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋ āύ⧇āχ, āĻāχāĻ­āĻžāĻŦ⧇ āĻ…āĻ¸ā§āϤāĻŋāĻ¤ā§āĻŦāĻšā§€āύ āϭ⧇āϰāĻŋāϝāĻŧ⧇āĻŦāϞ āĻ…ā§āϝāĻžāĻ•ā§āϏ⧇āϏ āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāϞ⧇ āĻāĻ•āϟāĻŋ [ReferenceError](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_defined) āϤ⧈āϰāĻŋ āĻšā§ŸāĨ¤

--- -###### 77. Is this a pure function? +###### 77. āĻāϟāĻŋ āĻ•āĻŋ āĻāĻ•āϟāĻŋ āĻŦāĻŋāĻļ⧁āĻĻā§āϧ āĻĢāĻžāĻ‚āĻļāύ? ```javascript function sum(a, b) { @@ -2477,9 +2477,9 @@ function sum(a, b) { #### āωāĻ¤ā§āϤāϰ: A -A pure function is a function that _always_ returns the same result, if the same arguments are passed. +āĻāĻ•āϟāĻŋ āĻŦāĻŋāĻļ⧁āĻĻā§āϧ āĻĢāĻžāĻ‚āĻļāύ āĻšāϞ āĻāĻŽāύ āĻāĻ•āϟāĻŋ āĻĢāĻžāĻ‚āĻļāύ āϝāĻž _āϏāĻŦāϏāĻŽāϝāĻŧ_ āĻāĻ•āχ āĻĢāϞāĻžāĻĢāϞ āĻĒā§āϰāĻĻāĻžāύ āĻ•āϰ⧇, āϝāĻĻāĻŋ āĻāĻ•āχ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āĻĒāĻžāϏ āĻ•āϰāĻž āĻšāϝāĻŧāĨ¤ -The `sum` function always returns the same result. If we pass `1` and `2`, it will _always_ return `3` without side effects. If we pass `5` and `10`, it will _always_ return `15`, and so on. This is the definition of a pure function. +`sum` āĻĢāĻžāĻ‚āĻļāύ āϏāĻŦāϏāĻŽāϝāĻŧ āĻāĻ•āχ āĻĢāϞāĻžāĻĢāϞ āĻĒā§āϰāĻĻāĻžāύ āĻ•āϰ⧇āĨ¤ āϝāĻĻāĻŋ āφāĻŽāϰāĻž `1` āĻāĻŦāĻ‚ `2` āĻĒāĻžāϏ āĻ•āϰāĻŋ, āĻāϟāĻŋ _āϏāĻŦāϏāĻŽāϝāĻŧ_ āĻĒāĻžāĻ°ā§āĻļā§āĻŦ āĻĒā§āϰāϤāĻŋāĻ•ā§āϰāĻŋāϝāĻŧāĻž āĻ›āĻžāĻĄāĻŧāĻžāχ `3` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤ āϝāĻĻāĻŋ āφāĻŽāϰāĻž `5` āĻāĻŦāĻ‚ `10` āĻĒāĻžāϏ āĻ•āϰāĻŋ, āϤāĻžāĻšāϞ⧇ āĻāϟāĻŋ _āϏāĻŦāϏāĻŽāϝāĻŧ_ `15` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇, āχāĻ¤ā§āϝāĻžāĻĻāĻŋāĨ¤ āĻāϟāĻŋāχ āĻšāϞ⧋ āĻāĻ•āϟāĻŋ āĻŦāĻŋāĻļ⧁āĻĻā§āϧ āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āϏāĻ‚āĻœā§āĻžāĻžāĨ¤

@@ -2518,15 +2518,17 @@ console.log(addFunction(5 * 2)); #### āωāĻ¤ā§āϤāϰ: C -The `add` function is a _memoized_ function. With memoization, we can cache the results of a function in order to speed up its execution. In this case, we create a `cache` object that stores the previously returned values. +`add` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻāĻ•āϟāĻŋ _memoized_ āĻĢāĻžāĻ‚āĻļāύāĨ¤ āĻŽā§‡āĻŽā§‹āĻžāφāχāĻœā§‡āĻļāύ⧇āϰ āϏāĻžāĻšāĻžāĻ¯ā§āϝ⧇, āφāĻŽāϰāĻž āĻāĻ•āϟāĻŋ āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āĻĢāϞāĻžāĻĢāϞāϗ⧁āϞāĻŋ āĻ•ā§āϝāĻžāĻļ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ (āĻ­āĻŦāĻŋāĻˇā§āϝāϤ⧇ āĻŦā§āϝāĻŦāĻšāĻžāϰ⧇āϰ āϜāĻ¨ā§āϝ āφāϞāĻžāĻĻāĻžāĻ­āĻžāĻŦ⧇ āϏāĻ‚āϰāĻ•ā§āώāĻŖ āĻ•āϰāĻžāϰ āĻĒāĻĻā§āϧāϤāĻŋ) āϝāĻžāϤ⧇ āĻāϟāĻŋ āĻ•āĻžāĻ°ā§āϝāĻ•āϰ āĻ•āϰāĻžāϰ (execution) āĻ—āϤāĻŋ āĻŦāĻžāĻĄāĻŧāĻžāύ⧋ āϝāĻžāϝāĻŧāĨ¤ āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āφāĻŽāϰāĻž āĻāĻ•āϟāĻŋ `cache` āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āϤ⧈āϰāĻŋ āĻ•āϰ⧇āĻ›āĻŋ āϝāĻž āĻĒā§‚āĻ°ā§āĻŦ⧇āϰ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻž āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞ⧋ āϏāĻ‚āϰāĻ•ā§āώāĻŖ āĻ•āϰ⧇āĨ¤ -If we call the `addFunction` function again with the same argument, it first checks whether it has already gotten that value in its cache. If that's the case, the cache value will be returned, which saves execution time. Otherwise, if it's not cached, it will calculate the value and store it afterward. +> āϝ⧇āĻšā§‡āϤ⧁ āĻāĻ–āĻžāύ⧇ `add` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻ…āĻ¨ā§āϝ āĻāĻ•āϟāĻŋ āĻĢāĻžāĻ‚āĻļāύāϕ⧇ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇ āϝ⧇ āϤāĻžāϰ āĻ¸ā§āϕ⧋āĻĒ⧇āϰ āĻŦāĻžāĻšāĻŋāϰ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁,`cache` āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇, āĻāĻ•ā§āϏ⧇āϏ āĻ•āϰāϛ⧇āĨ¤ āĻĢāϞ⧇ āĻāĻ–āĻžāύ⧇ āĻāĻ•āϟāĻŋ [āĻ•ā§āϞ⧋āϜāĻžāϰ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures) āϤ⧈āϰāĻŋ āĻšā§Ÿā§‡āϛ⧇āĨ¤ -We call the `addFunction` function three times with the same value: on the first invocation, the value of the function when `num` is equal to `10` isn't cached yet. The condition of the if-statement `num in cache` returns `false`, and the else block gets executed: `Calculated! 20` gets logged, and the value of the result gets added to the cache object. `cache` now looks like `{ 10: 20 }`. +āϝāĻĻāĻŋ āφāĻŽāϰāĻž āĻāĻ•āχ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āϏāĻžāĻĨ⧇ āφāĻŦāĻžāϰ `addFunction` āĻĢāĻžāĻ‚āĻļāύāϕ⧇ āĻ•āϞ āĻ•āϰāĻŋ, āĻāϟāĻŋ āĻĒā§āϰāĻĨāĻŽā§‡ āĻĒāϰ⧀āĻ•ā§āώāĻž āĻ•āϰ⧇ āϝ⧇ āϏ⧇āχ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āχāϤāĻŋāĻŽāĻ§ā§āϝ⧇ cache-āĻĨ⧇āϕ⧇ āĻĒ⧇āϝāĻŧ⧇āϛ⧇ āĻ•āĻŋāύāĻžāĨ¤ āϝāĻĻāĻŋ āĻĒāĻžā§Ÿ, cache-āĻĨ⧇āϕ⧇āχ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻž āĻšāĻŦ⧇, āϝāĻž āĻāĻ•ā§āϏāĻŋāĻ•āĻŋāωāĻļāύ⧇āϰ āϏāĻŽāϝāĻŧ āĻŦāĻžāρāϚāĻžāϝāĻŧāĨ¤ āĻ…āĻ¨ā§āϝāĻĨāĻžāϝāĻŧ, cache-āĻĨ⧇āϕ⧇ āύāĻž āĻĒ⧇āϞ⧇, āĻāϟāĻŋ āĻ—āĻŖāύāĻž āĻ•āϰ⧇ āĻĒā§āϰāĻžāĻĒā§āϤ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āϏāĻ‚āϰāĻ•ā§āώāĻŖ āĻ•āϰāĻŦ⧇āĨ¤ -The second time, the `cache` object contains the value that gets returned for `10`. The condition of the if-statement `num in cache` returns `true`, and `'From cache! 20'` gets logged. +āφāĻŽāϰāĻž āĻāĻ•āχ āĻ­ā§āϝāĻžāϞ⧁ āĻĻāĻŋā§Ÿā§‡ `addFunction` āĻĢāĻžāĻ‚āĻļāύāϕ⧇ āĻ•āϞ āĻ•āϰāĻ›āĻŋ ā§Š āĻŦāĻžāϰāσ ā§§āĻŽ āĻ•āϞ⧇āϰ āϏāĻŽā§Ÿ, āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁ cache-āĻ āύ⧇āχ āϝāĻ–āύ `num` āϏāĻŽāĻžāύ āϏāĻŽāĻžāύ āĻšā§Ÿ `10`āĨ¤ āχāĻĢ-āĻ¸ā§āĻŸā§‡āϟāĻŽā§āϝāĻžāĻ¨ā§āĻŸā§‡āϰ āĻļāĻ°ā§āϤ `num in cache` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `false`, āĻāĻŦāĻ‚ āĻāϞāϏ āĻŦā§āϞāĻ• āĻāĻ•ā§āϏāĻŋāĻ•āĻŋāωāϟ āĻšā§Ÿā§‡āϛ⧇āσ `Calculated! 20` āϞāĻ— āĻšā§Ÿ, āĻāĻŦāĻ‚ result-āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ cache āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āϏāĻ‚āϰāĻ•ā§āώāĻŋāϤ āĻšā§ŸāĨ¤ `cache` āĻāĻ–āύ āĻšā§Ÿ - `{ 10: 20 }`āĨ¤ -The third time, we pass `5 * 2` to the function which gets evaluated to `10`. The `cache` object contains the value that gets returned for `10`. The condition of the if-statement `num in cache` returns `true`, and `'From cache! 20'` gets logged. +⧍⧟ āĻŦāĻžāϰ⧇, `cache` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ `10` āĻāϰ āϜāĻ¨ā§āϝ āϝ⧇ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻž āĻšā§Ÿā§‡āĻ›āĻŋāϞ⧋ āϏ⧇āϟāĻŋ āφāϛ⧇āĨ¤ āχāĻĢ-āĻ¸ā§āĻŸā§‡āϟāĻŽā§āϝāĻžāύāĻ¨ā§āĻŸā§‡āϰ āĻļāĻ°ā§āϤ `num in cache` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `true`, āĻāĻŦāĻ‚ āϞāĻ— āĻšā§Ÿ `'From cache! 20'`āĨ¤ + +ā§Šā§Ÿ āĻŦāĻžāϰ⧇, āĻĢāĻžāĻ‚āĻļāύ⧇ āφāĻŽāϰāĻž āĻĒāĻžāϏ āĻ•āϰ⧇āĻ›āĻŋ `5 * 2` āϝ⧇āϟāĻž āĻŽā§‚āĻ˛ā§āϝāĻžā§ŸāĻŋāϤ āĻšā§Ÿ `10`āĨ¤ `cache` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ `10` āĻāϰ āϜāĻ¨ā§āϝ āϝ⧇ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻž āĻšā§Ÿā§‡āĻ›āĻŋāϞ⧋ āϏ⧇āϟāĻŋ āφāϛ⧇āĨ¤ āχāĻĢ-āĻ¸ā§āĻŸā§‡āϟāĻŽā§āϝāĻžāύāĻ¨ā§āĻŸā§‡āϰ āĻļāĻ°ā§āϤ `num in cache` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `true`, āĻāĻŦāĻ‚ āϞāĻ— āĻšā§Ÿ `'From cache! 20'`āĨ¤

@@ -2557,13 +2559,13 @@ for (let item of myLifeSummedUp) { #### āωāĻ¤ā§āϤāϰ: A -With a _for-in_ loop, we can iterate over **enumerable** properties. In an array, the enumerable properties are the "keys" of array elements, which are actually their indexes. You could see an array as: +āĻāĻ•āϟāĻŋ _for-in_ āϞ⧁āĻĒ āĻĻāĻŋāϝāĻŧ⧇, āφāĻŽāϰāĻž **āĻ—āĻŖāύāĻžāϝ⧋āĻ—ā§āϝ (enumerable)** āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϰ āωāĻĒāϰ āϞ⧁āĻĒ āϚāĻžāϞāĻžāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ āĻ…ā§āϝāĻžāϰ⧇āϤ⧇ āĻ—āĻŖāύāĻžāϝ⧋āĻ—ā§āϝ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϗ⧁āϞ⧋ āĻšā§Ÿ āĻ…ā§āϝāĻžāϰ⧇āϰ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ "āϕ⧀", āϝāĻž āφāϏāϞ⧇ āϤāĻžāĻĻ⧇āϰ āχāύāĻĄā§‡āĻ•ā§āϏāĨ¤ āφāĻĒāύāĻŋ āĻ…ā§āϝāĻžāϰ⧇āϟāĻŋāϕ⧇ āĻĻ⧇āĻ–āϤ⧇ āĻĒāĻžāĻŦ⧇āύ āĻāĻŽāύ: `{0: "☕", 1: "đŸ’ģ", 2: "🍷", 3: "đŸĢ"}` -Where the keys are the enumerable properties. `0` `1` `2` `3` get logged. +āϝ⧇āĻ–āĻžāύ⧇ āϕ⧀āϗ⧁āϞāĻŋ āĻ—āĻŖāύāĻžāϝ⧋āĻ—ā§āϝ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāĨ¤ āϤāĻžāχ `0` `1` `2` `3` āϞāĻ— āĻšā§Ÿā§‡āϛ⧇āĨ¤ -With a _for-of_ loop, we can iterate over **iterables**. An array is an iterable. When we iterate over the array, the variable "item" is equal to the element it's currently iterating over, `"☕"` `"đŸ’ģ"` `"🍷"` `"đŸĢ"` get logged. +āĻāĻ•āϟāĻŋ _for-of_ āϞ⧁āĻĒ āĻĻāĻŋāϝāĻŧ⧇, āφāĻŽāϰāĻž **āĻĒ⧁āύāϰāĻžāĻŦ⧃āĻ¤ā§āϤāĻŋāϝ⧋āĻ—ā§āϝ (iteables)** āĻāϰ āωāĻĒāϰ āϞ⧁āĻĒ āϚāĻžāϞāĻžāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ āĻ…ā§āϝāĻžāϰ⧇ āĻĒ⧁āύāϰāĻžāĻŦ⧃āĻ¤ā§āϤāĻŋāϝ⧋āĻ—ā§āϝāĨ¤ āϝāĻ–āύ āφāĻŽāϰāĻž āĻ…ā§āϝāĻžāϰ⧇āϰ āωāĻĒāϰ āϞ⧁āĻĒ āϚāĻžāϞāĻžāχ, āϤāĻ–āύ "item" āϭ⧇āϰāĻŋāϝāĻŧ⧇āĻŦāϞāϟāĻŋ āĻŦāĻ°ā§āϤāĻŽāĻžāύ⧇ āĻĒ⧁āύāϰāĻžāĻŦ⧃āĻ¤ā§āϤāĻŋ āĻšāĻšā§āϛ⧇ āϏ⧇āχ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āϏāĻŽāĻžāύāĨ¤ āϤāĻžāχ `"☕"` `"đŸ’ģ"` `"🍷"` `"đŸĢ"` āϞāĻ— āĻšāϝāĻŧ⧇āϛ⧇āĨ¤

@@ -2587,9 +2589,9 @@ console.log(list); #### āωāĻ¤ā§āϤāϰ: C -Array elements can hold any value. Numbers, strings, objects, other arrays, null, boolean values, undefined, and other expressions such as dates, functions, and calculations. +āĻ…ā§āϝāĻžāϰ⧇ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟāϗ⧁āϞ⧋ āϝ⧇āϕ⧋āύ āϟāĻžāχāĻĒ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁ āϰāĻžāĻ–āϤ⧇ āĻĒāĻžāϰ⧇āĨ¤ āύāĻžāĻŽā§āĻŦāĻžāϰ, āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚, āĻ…āĻžā§āĻœā§‡āĻ•ā§āϟ, āĻ…āĻ¨ā§āϝ āĻ…ā§āϝāĻžāϰ⧇, āύāĻžāϞ, āĻŦ⧁āϞāĻŋ⧟āĻžāύ, āφāĻ¨ā§āĻĄāĻŋāĻĢāĻžāχāĻ¨ā§āĻĄ, āĻāĻŦāĻ‚ āĻ…āĻ¨ā§āϝāĻžāĻ¨ā§āϝ āĻāĻ•ā§āϏāĻĒā§āϰ⧇āĻļāύ āϝ⧇āĻŽāύ, āϤāĻžāϰāĻŋāĻ–, āĻĢāĻžāĻ‚āĻļāύ, āĻ“ āϝ⧇āϗ⧁āϞ⧋ āĻ—āύāύāĻž āϝ⧋āĻ—ā§āϝāĨ¤ -The element will be equal to the returned value. `1 + 2` returns `3`, `1 * 2` returns `2`, and `1 / 2` returns `0.5`. +āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟāϗ⧁āϞ⧋ āϏāĻŽāĻžāύ āĻšāĻŦ⧇ āϤāĻžāϰ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ­ā§āϝāĻžāϞ⧁āĨ¤ `1 + 2` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `3`, `1 * 2` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `2`, āĻāĻŦāĻ‚ `1 / 2` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `0.5`āĨ¤

From dcc887f101c631e38b354b39dea6305acb91e823 Mon Sep 17 00:00:00 2001 From: iamsaief Date: Tue, 4 Jun 2024 07:54:11 +0600 Subject: [PATCH 06/12] added translation till 90 --- bn-BD/README_bn-BD.md | 64 +++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/bn-BD/README_bn-BD.md b/bn-BD/README_bn-BD.md index f292c293..ac3379fe 100644 --- a/bn-BD/README_bn-BD.md +++ b/bn-BD/README_bn-BD.md @@ -2486,7 +2486,7 @@ function sum(a, b) { --- -###### 78. What is the output? +###### 78. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript const add = () => { @@ -2535,7 +2535,7 @@ console.log(addFunction(5 * 2)); --- -###### 79. What is the output? +###### 79. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript const myLifeSummedUp = ['☕', 'đŸ’ģ', '🍷', 'đŸĢ']; @@ -2572,7 +2572,7 @@ for (let item of myLifeSummedUp) { --- -###### 80. What is the output? +###### 80. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript const list = [1 + 2, 1 * 2, 1 / 2]; @@ -2598,7 +2598,7 @@ console.log(list); --- -###### 81. What is the output? +###### 81. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript function sayHi(name) { @@ -2618,20 +2618,20 @@ console.log(sayHi()); #### āωāĻ¤ā§āϤāϰ: B -By default, arguments have the value of `undefined`, unless a value has been passed to the function. In this case, we didn't pass a value for the `name` argument. `name` is equal to `undefined` which gets logged. +āĻĄāĻŋāĻĢāĻ˛ā§āϟāĻ­āĻžāĻŦ⧇, āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟāϗ⧁āϞ⧋āϰ āĻ­ā§āϝāĻžāϞ⧁ āĻĨāĻžāϕ⧇ `undefined`, āϝāĻĻāĻŋ āĻĢāĻžāĻ‚āĻļāύ⧇ āϕ⧋āύ āĻāĻ•āϟāĻŋ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāϏ āĻ•āϰāĻž āύāĻž āĻšā§ŸāĨ¤ āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āφāĻŽāϰāĻž `name` āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āϜāĻ¨ā§āϝ āϕ⧋āύ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāϏ āĻ•āϰāĻŋ āύāĻŋāĨ¤ `name` āϏāĻŽāĻžāύ āĻšā§Ÿ `undefined`, āϝ⧇āϟāĻŋ āϞāĻ— āĻšā§Ÿā§‡āϛ⧇āĨ¤ -In ES6, we can overwrite this default `undefined` value with default parameters. For example: +āχāĻāϏā§Ŧ āĻ, āφāĻŽāϰāĻž āĻāχ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻ­ā§āϝāĻžāϞ⧁ `undefined` āϕ⧇ āĻ“āĻ­āĻžāϰāϰāĻžāχāϟ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ āĻĻāĻŋā§Ÿā§‡āĨ¤ āωāĻĻāĻžāĻšāϰāύāϏāϰ⧂āĻĒāσ `function sayHi(name = "Lydia") { ... }` -In this case, if we didn't pass a value or if we passed `undefined`, `name` would always be equal to the string `Lydia` +āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āφāĻŽāϰāĻž āϝāĻĻāĻŋ āϕ⧋āύ āĻāĻ•āϟāĻŋ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāϏ āύāĻž āĻ•āϰāĻŋ āĻŦāĻž `undefined` āĻĒāĻžāϏ āĻ•āϰāĻŋ, `name` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āϏāĻŦāϏāĻŽā§Ÿ `Lydia` āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āϟāĻŋāϰ āϏāĻŽāĻžāύ āĻšāĻŦ⧇āĨ¤

--- -###### 82. What is the output? +###### 82. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript var status = '😎'; @@ -2661,16 +2661,16 @@ setTimeout(() => { #### āωāĻ¤ā§āϤāϰ: B -The value of the `this` keyword is dependent on where you use it. In a **method**, like the `getStatus` method, the `this` keyword refers to _the object that the method belongs to_. The method belongs to the `data` object, so `this` refers to the `data` object. When we log `this.status`, the `status` property on the `data` object gets logged, which is `"đŸĨ‘"`. +`this` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄā§‡āϰ āĻŽāĻžāύ āύāĻŋāĻ°ā§āĻ­āϰ āĻ•āϰ⧇ āφāĻĒāύāĻŋ āĻāϟāĻŋ āϕ⧋āĻĨāĻžāϝāĻŧ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāϛ⧇āύ āϤāĻžāϰ āωāĻĒāϰāĨ¤ āĻāĻ•āϟāĻŋ **āĻŽā§‡āĻĨāĻĄā§‡**-āĻ, āϝ⧇āĻŽāύ `getStatus` āĻŽā§‡āĻĨāĻĄā§‡, `this` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄāϟāĻŋ _āϏ⧇āχ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āĻŦā§‹āĻāĻžā§Ÿ āĻŽā§‡āĻĨāĻĄāϟāĻŋ āϝāĻžāϰ āϭ⧇āϤāϰ⧇ āĻĨāĻžāϕ⧇_āĨ¤ āĻŽā§‡āĻĨāĻĄāϟāĻŋ `data` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻ…āĻ¨ā§āϤāĻ°ā§āĻ—āϤ, `this` āϤāĻžāχ `data` āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āϰ⧇āĻĢāĻžāϰ āĻ•āϰ⧇āĨ¤ āϝāĻ–āύ āφāĻŽāϰāĻž `this.status` āϞāĻ— āĻ•āϰāĻŋ, `data` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ `status` āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āϞāĻ— āĻšāϝāĻŧ, āϝāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁ `"đŸĨ‘"`āĨ¤ -With the `call` method, we can change the object to which the `this` keyword refers. In **functions**, the `this` keyword refers to the _the object that the function belongs to_. We declared the `setTimeout` function on the _global object_, so within the `setTimeout` function, the `this` keyword refers to the _global object_. On the global object, there is a variable called _status_ with the value of `"😎"`. When logging `this.status`, `"😎"` gets logged. +`call` āĻŽā§‡āĻĨāĻĄā§‡āϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡, āφāĻŽāϰāĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ `this` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄāϟāĻŋ āϝāĻžāϕ⧇ āϰ⧇āĻĢāĻžāϰ āĻ•āϰ⧇āĨ¤ **āĻĢāĻžāĻ‚āĻļāύ**-āĻ, `this` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄāϟāĻŋ _āϏ⧇āχ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āĻŦā§‹āĻāĻžāϝāĻŧ āϝ⧇āϟāĻŋ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋāϰ āĻ…āĻ¨ā§āϤāĻ°ā§āĻ—āϤ_āĨ¤ āφāĻŽāϰāĻž _āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ_-āĻ `setTimeout` āĻĢāĻžāĻ‚āĻļāύ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰ⧇āĻ›āĻŋ, āϤāĻžāχ `setTimeout` āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āĻŽāĻ§ā§āϝ⧇, `this` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄāϟāĻŋ _āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ_ āϕ⧇ āϰ⧇āĻĢāĻžāϰ āĻ•āϰ⧇āĨ¤ āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡, _status_ āύāĻžāĻŽāĻ• āĻāĻ•āϟāĻŋ āϭ⧇āϰāĻŋāϝāĻŧ⧇āĻŦāϞ āφāϛ⧇ āϝāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁ `"😎"`āĨ¤ āϤāĻžāχ `this.status` āϞāĻ— āĻ•āϰāĻžā§Ÿ `"😎"` āϞāĻ— āĻšā§ŸāĨ¤

--- -###### 83. What is the output? +###### 83. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript const person = { @@ -2694,20 +2694,20 @@ console.log(person); #### āωāĻ¤ā§āϤāϰ: A -We set the variable `city` equal to the value of the property called `city` on the `person` object. There is no property on this object called `city`, so the variable `city` has the value of `undefined`. +āφāĻŽāϰāĻž `city` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁ āϏāĻŽāĻžāύ āϏ⧇āϟ āĻ•āϰāĻ›āĻŋ `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ `city` āύāĻžāĻŽāĻ• āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇āĨ¤ āĻāχ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ `city` āύāĻžāĻŽāĻ• āϕ⧋āύ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āύ⧇āχ, āϤāĻžāχ `city` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁ āĻĨāĻžāĻ•āϛ⧇ `undefined`āĨ¤ -Note that we are _not_ referencing the `person` object itself! We simply set the variable `city` equal to the current value of the `city` property on the `person` object. +āĻ–ā§‡ā§ŸāĻžāϞ āĻ•āϰ⧁āύ āφāĻŽāϰāĻž āĻ•āĻŋāĻ¨ā§āϤ⧁ `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāĻŋāϕ⧇ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ (āύāĻŋāĻ°ā§āĻĻ⧇āĻļ) _āĻ•āϰāĻ›āĻŋ āύāĻž_! āφāĻŽāϰāĻž āϏāĻžāϧāĻžāϰāύ āĻ­āĻžāĻŦ⧇āχ `city` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁ āϏāĻŽāĻžāύ āϏ⧇āϟ āĻ•āϰāĻ›āĻŋ `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ `city` āύāĻžāĻŽāĻ• āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϰ āĻŦāĻ°ā§āϤāĻŽāĻžāύ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇āĨ¤ -Then, we set `city` equal to the string `"Amsterdam"`. This doesn't change the person object: there is no reference to that object. +āĻĒāϰāĻŦāĻ°ā§āϤāĻŋāϤ⧇, `city` āϏāĻŽāĻžāύ āϏ⧇āϟ āĻ•āϰāĻ›āĻŋ āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚-`"Amsterdam"`āĨ¤ āĻāϟāĻž person āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āϕ⧋āύ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāϛ⧇ āύāĻžāσ āĻāĻ–āĻžāύ⧇ āϐ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϕ⧋āύ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āύ⧇āχāĨ¤ -When logging the `person` object, the unmodified object gets returned. +āϝāĻ–āύ `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāĻŋāϕ⧇ āϞāĻ— āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇, āĻ…āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāĻŋāϤ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāĻŋāχ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻšā§Ÿā§‡āϛ⧇āĨ¤

--- -###### 84. What is the output? +###### 84. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript function checkAge(age) { @@ -2733,14 +2733,14 @@ console.log(checkAge(21)); #### āωāĻ¤ā§āϤāϰ: C -Variables with the `const` and `let` keywords are _block-scoped_. A block is anything between curly brackets (`{ }`). In this case, the curly brackets of the if/else statements. You cannot reference a variable outside of the block it's declared in, a ReferenceError gets thrown. +`const` āĻ“ `let` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄ āĻĻāĻŋā§Ÿā§‡ āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞāϗ⧁āϞ⧋ āĻšā§Ÿ _āĻŦā§āϞāĻ•-āĻ¸ā§āϕ⧋āĻĒāĻĄ_āĨ¤ āĻāĻ•āϟāĻŋ āĻŦā§āϞāĻ• āĻšāϞ⧋ āĻ•āĻžāĻ°ā§āϞāĻŋ āĻŦā§āĻ°ā§āϝāĻžāϕ⧇āĻŸā§‡āϰ (`{ }`) āϭ⧇āϤāϰ⧇āϰ āϝ⧇āϕ⧋āύ āĻ•āĻŋāϛ⧁āχāĨ¤ āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āχāĻĢ-āĻāϞāϏ āĻ¸ā§āĻŸā§‡āϟāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āĻ•āĻžāĻ°ā§āϞāĻŋ āĻŦā§āĻ°ā§āϝāĻžāϕ⧇āϟāĨ¤ āφāĻĒāύāĻŋ āϕ⧋āύ āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞāϕ⧇ āϝ⧇ āĻŦā§āϞāϕ⧇ āϤāĻžāĻĻ⧇āϰ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇ āϤāĻžāϰ āĻŦāĻžāχāϰ⧇ āĻĨ⧇āϕ⧇ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŦ⧇āύ āύāĻž, āĻāĻ•āϟāĻŋ ReferenceError āĻšā§ŸāĨ¤

--- -###### 85. What kind of information would get logged? +###### 85. āĻāĻ–āĻžāύ⧇ āĻ•āĻŋ āϧāϰāύ⧇āϰ āϤāĻĨā§āϝ āϞāĻ— āĻšāϤ⧇ āĻĒāĻžāϰ⧇? ```javascript fetch('https://www.website.com/api/user/1') @@ -2758,14 +2758,14 @@ fetch('https://www.website.com/api/user/1') #### āωāĻ¤ā§āϤāϰ: C -The value of `res` in the second `.then` is equal to the returned value of the previous `.then`. You can keep chaining `.then`s like this, where the value is passed to the next handler. +⧍āϝāĻŧ `.then`-āĻ `res` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻĒā§‚āĻ°ā§āĻŦāĻŦāĻ°ā§āϤ⧀ `.then`-āĻāϰ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻž āĻ­ā§āϝāĻžāϞ⧁āϰ āϏāĻŽāĻžāύāĨ¤ āφāĻĒāύāĻŋ āĻāĻ­āĻžāĻŦ⧇ `.then`-āϗ⧁āϞ⧋āϰ āĻšā§‡āχāύ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āύ, āϝ⧇āĻ–āĻžāύ⧇ āĻŦāĻ°ā§āϤāĻŽāĻžāύ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻĒāϰāĻŦāĻ°ā§āϤ⧀ āĻšā§āϝāĻžāĻ¨ā§āĻĄāϞāĻžāϰ⧇āϰ āĻ•āĻžāϛ⧇ āϚāϞ⧇ āϝāĻžāϝāĻŧāĨ¤

--- -###### 86. Which option is a way to set `hasName` equal to `true`, provided you cannot pass `true` as an argument? +###### 86. āϕ⧋āύ āĻ…āĻĒāĻļāύāϟāĻŋ `hasName` āϕ⧇ `true` āĻāϰ āϏāĻŽāĻžāύ āϏ⧇āϟ āĻ•āϰāĻžāϰ āĻāĻ•āϟāĻŋ āωāĻĒāĻžāϝāĻŧ, āϝāĻĻāĻŋ āφāĻĒāύāĻŋ `true` āϕ⧇ āĻāĻ•āϟāĻŋ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āĻšāĻŋāϏ⧇āĻŦ⧇ āĻĒāĻžāϏ āĻ•āϰāϤ⧇ āύāĻž āĻĒāĻžāϰ⧇āύ? ```javascript function getName(name) { @@ -2783,13 +2783,13 @@ function getName(name) { #### āωāĻ¤ā§āϤāϰ: A -With `!!name`, we determine whether the value of `name` is truthy or falsy. If the name is truthy, which we want to test for, `!name` returns `false`. `!false` (which is what `!!name` practically is) returns `true`. +A-āϰ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, `!!name` āĻĻāĻŋāϝāĻŧ⧇, āφāĻŽāϰāĻž āύāĻŋāĻ°ā§āϧāĻžāϰāĻŖ āĻ•āϰāĻŋ `name` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āϏāĻ¤ā§āϝ āύāĻžāĻ•āĻŋ āĻŽāĻŋāĻĨā§āϝāĻžāĨ¤ āϝāĻĻāĻŋ āύāĻžāĻŽāϟāĻŋ āϏāĻ¤ā§āϝ āĻšāϝāĻŧ, āϝāĻžāϰ āϜāĻ¨ā§āϝ āφāĻŽāϰāĻž āĻĒāϰ⧀āĻ•ā§āώāĻž āĻ•āϰāϤ⧇ āϚāĻžāχ, `!name` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `false`āĨ¤ `!false` (āϝ⧇āϟāĻŋ āĻŦāĻžāĻ¸ā§āϤāĻŦāĻŋāĻ•āĻ­āĻžāĻŦ⧇āχ `!!name`) āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `true`āĨ¤ -By setting `hasName` equal to `name`, you set `hasName` equal to whatever value you passed to the `getName` function, not the boolean value `true`. +B-āϰ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, `hasName` āϏāĻŽāĻžāύ `name` āϏ⧇āϟ āĻ•āϰāĻžāϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡, āφāĻĒāύāĻŋ `hasName` āϏāĻŽāĻžāύ āĻ•āϰāϛ⧇āύ `getName` āĻĢāĻžāĻ‚āĻļāύ⧇ āĻĒāĻžāϏ āĻ•āϰāĻž āϝ⧇āϕ⧋āύ āĻ­ā§āϝāĻžāϞ⧁, āĻŦ⧁āϞāĻŋāϝāĻŧāĻžāύ `true` āĻ­ā§āϝāĻžāϞ⧁ āύāϝāĻŧāĨ¤ -`new Boolean(true)` returns an object wrapper, not the boolean value itself. +C-āϰ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, `new Boolean(true)` āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻ°â€ā§āϝāĻžāĻĒāĻžāϰ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇, āϤāĻžāϰ āĻŦ⧁āϞāĻŋāϝāĻŧāĻžāύ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇ āύāϝāĻŧāĨ¤ -`name.length` returns the length of the passed argument, not whether it's `true`. +D-āϰ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, `name.length` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ āĻĒāĻžāϏ āĻ•āϰāĻž āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āĻĻ⧈āĻ°ā§āĻ˜ā§āϝ, āĻāϟāĻŋ `true` āĻ•āĻŋāύāĻž āϤāĻž āύāϝāĻŧāĨ¤

@@ -2812,9 +2812,9 @@ console.log('I want pizza'[0]); #### āωāĻ¤ā§āϤāϰ: B -In order to get a character at a specific index of a string, you can use bracket notation. The first character in the string has index 0, and so on. In this case, we want to get the element with index 0, the character `"I'`, which gets logged. +āĻ¸ā§āĻŸā§āϰāĻŋ-āĻāϰ āϕ⧋āύ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āχāύāĻĄā§‡āĻ•ā§āϏ⧇āϰ āĻ…āĻ•ā§āώāϰāϕ⧇ āĻĒāĻžāĻ“ā§ŸāĻžāϰ āϜāĻ¨ā§āϝ, āφāĻĒāύāĻŋ āĻŦā§āĻ°ā§āϝāĻžāϕ⧇āϟ āύ⧋āĻŸā§‡āĻļāύ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āύāĨ¤ āĻ¸ā§āĻŸā§āϰāĻŋ-āĻāϰ ā§§āĻŽ āĻ…āĻ•ā§āώāϰ⧇āϰ āχāύāĻĄā§‡āĻ•ā§āϏ āĻšā§Ÿ 0, āĻāĻŦāĻ‚ āĻāĻ­āĻžāĻŦ⧇ āĻĒāϰ⧇āϰ āχāύāĻĄā§‡āĻ•ā§āϏāϗ⧁āϞ⧋āϤ⧇ āĻŦāĻžāĻ•āĻŋ āĻ…āĻ•ā§āώāϰāϗ⧁āϞ⧋ āĻĨāĻžāϕ⧇āĨ¤ āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āφāĻŽāϰāĻž 0 āχāύāĻĄā§‡āĻ•ā§āϏ⧇āϰ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟāϕ⧇ āĻĒ⧇āϤ⧇ āϚāĻžāĻšā§āĻ›āĻŋ, `"I'` āĻ…āĻ•ā§āώāϰāϟāĻŋ, āϝ⧇āϟāĻž āϞāĻ— āĻšā§Ÿā§‡āϛ⧇āĨ¤ -Note that this method is not supported in IE7 and below. In that case, use `.charAt()`. +āĻŽāύ⧇ āϰāĻžāĻ–āĻŦ⧇āύ āϝ⧇ āĻāχ āĻŽā§‡āĻĨāĻĄāϟāĻŋ IE7 āĻāĻŦāĻ‚ āύ⧀āĻšā§‡ āϏāĻžāĻĒā§‹āĻ°ā§āϟ āĻ•āϰ⧇ āύāĻžāĨ¤ āϏ⧇āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ `.charAt()` āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧁āύāĨ¤

@@ -2841,9 +2841,9 @@ sum(10); #### āωāĻ¤ā§āϤāϰ: B -You can set a default parameter's value equal to another parameter of the function, as long as they've been defined _before_ the default parameter. We pass the value `10` to the `sum` function. If the `sum` function only receives 1 argument, it means that the value for `num2` is not passed, and the value of `num1` is equal to the passed value `10` in this case. The default value of `num2` is the value of `num1`, which is `10`. `num1 + num2` returns `20`. +āφāĻĒāύāĻŋ āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇ āϏāĻŽāĻžāύ āĻ…āĻ¨ā§āϝ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŦ⧇āύ, āϝāϤāĻ•ā§āώāĻŖ āĻĒāĻ°ā§āϝāĻ¨ā§āϤ āϤāĻžāϰāĻž āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ⧇āϰ _āφāϗ⧇_ āĻĄāĻŋāĻĢāĻžāχāύ āĻ•āϰāĻž āĻĨāĻžāϕ⧇āĨ¤ āφāĻŽāϰāĻž `sum` āĻĢāĻžāĻ‚āĻļāύ⧇ `10` āĻ­ā§āϝāĻžāϞ⧁āϕ⧇ āĻĒāĻžāϏ āĻ•āϰāĻ›āĻŋāĨ¤ āϝāĻĻāĻŋ `sum` āĻĢāĻžāĻ‚āĻļāύ āĻāĻ•āϟāĻŋ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āϰāĻŋāϏāĻŋāĻ­ āĻ•āϰ⧇, āĻāϰ āĻŽāĻžāύ⧇ āĻšāϞ⧋ `num2` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāϏ āĻ•āϰāĻž āĻšā§ŸāύāĻŋ, āĻāĻŦāĻ‚ `num1` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āϏāĻŽāĻžāύ āĻšāϞ āĻĒāĻžāϏ āĻ•āϰāĻž āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ `10` āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇āĨ¤ `num2` āĻāϰ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻ­ā§āϝāĻžāϞ⧁ āĻšāϞ `num1`, āϝ⧇āϟāĻž `10`āĨ¤ `num1 + num2` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āϛ⧇ `20`āĨ¤ -If you're trying to set a default parameter's value equal to a parameter that is defined _after_ (to the right), the parameter's value hasn't been initialized yet, which will throw an error. +āϝāĻĻāĻŋ āφāĻĒāύāĻŋ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇ āϏāĻŽāĻžāύ āĻ…āĻ¨ā§āϝ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ āĻ•āϰāϤ⧇ āϚāĻžāύ āϝ⧇āϟāĻž _āĻĒāϰ⧇_ āĻĄāĻŋāĻĢāĻžāχāύ āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇ (āĻĄāĻžāύ āĻĒāĻžāĻļ⧇āϰ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ), āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āϤāĻ–āύ⧋ āχāύāĻŋāĻļāĻŋ⧟āĻžāϞāĻžāχāϜ (āĻ­ā§āϝāĻžāϞ⧁ āϏ⧇āϟ āĻ•āϰāĻž) āĻšā§Ÿ āύāĻŋ, āϏ⧇āϟāĻŋ āĻāĻ•āϟāĻŋ āĻāϰāϰ āĻĨā§āϰ⧋ āĻ•āϰāĻŦ⧇āĨ¤

@@ -2873,9 +2873,9 @@ console.log(data); #### āωāĻ¤ā§āϤāϰ: A -With the `import * as name` syntax, we import _all exports_ from the `module.js` file into the `index.js` file as a new object called `data` is created. In the `module.js` file, there are two exports: the default export, and a named export. The default export is a function that returns the string `"Hello World"`, and the named export is a variable called `name` which has the value of the string `"Lydia"`. +`import * as name` āϏāĻŋāύāĻŸā§āϝāĻžāĻ•ā§āϏ āĻĻāĻŋā§Ÿā§‡, āφāĻŽāϰāĻž `module.js` āĻĢāĻžāχāϞ āĻĨ⧇āϕ⧇ _āϏāĻ•āϞ āĻāĻ•ā§āϏāĻĒā§‹āĻ°ā§āϟ_-āϗ⧁āϞ⧋āϕ⧇ `index.js` āĻĢāĻžāχāϞ⧇ āχāĻŽā§āĻĒā§‹āĻ°ā§āϟ āĻ•āϰāĻ›āĻŋ `data` āύāĻžāĻŽā§‡āϰ āĻāĻ•āϟāĻŋ āύāϤ⧁āύ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻšāĻŋāϏ⧇āĻŦ⧇āĨ¤ `module.js` āĻĢāĻžāχāϞ⧇, āĻĻ⧁āϟāĻŋ āĻāĻ•ā§āϏāĻĒā§‹āĻ°ā§āϟ āφāϛ⧇āσ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻāĻ•ā§āϏāĻĒā§‹āĻ°ā§āϟ āĻ“ āĻāĻ•āϟāĻŋ āύ⧇āĻŽāĻĄ āĻāĻ•ā§āϏāĻĒā§‹āĻ°ā§āϟāĨ¤ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻāĻ•ā§āϏāĻĒā§‹āĻ°ā§āϟāϟāĻŋ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧋ āĻĢāĻžāĻ‚āĻļāύ āϝ⧇ `"Hello World"` āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āϟāĻŋ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇, āĻāĻŦāĻ‚ āύ⧇āĻŽāĻĄ āĻāĻ•ā§āϏāĻĒā§‹āĻ°ā§āϟāϟāĻŋ āĻšāϞ `name` āύāĻžāĻŽā§‡āϰ āĻāϟāĻŋ āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞ āϝ⧇āϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻšāϞ `"Lydia"` āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āϟāĻŋāĨ¤ -The `data` object has a `default` property for the default export, other properties have the names of the named exports and their corresponding values. +`data` āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϟāĻŋāϤ⧇ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻāĻ•ā§āϏāĻĒā§‹āĻ°ā§āĻŸā§‡āϰ āϜāĻ¨ā§āϝ āĻāĻ•āϟāĻŋ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āφāϛ⧇ `default`, āĻ…āĻ¨ā§āϝāĻžāĻ¨ā§āϝ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϤ⧇ āφāϛ⧇ āύ⧇āĻŽāĻĄ āĻāĻ•ā§āϏāĻĒā§‹āĻ°ā§āĻŸā§‡āϰ āύāĻžāĻŽāϗ⧁āϞ⧋ āĻ“ āϤāĻžāĻĻ⧇āϰ āϏāĻ‚āĻļā§āϞāĻŋāĻˇā§āϟ āĻ­ā§āϝāĻžāϞ⧁āĨ¤

@@ -2905,7 +2905,7 @@ console.log(typeof member); #### āωāĻ¤ā§āϤāϰ: C -Classes are syntactical sugar for function constructors. The equivalent of the `Person` class as a function constructor would be: +āĻ•ā§āϞāĻžāϏāϗ⧁āϞāĻŋ āĻšāϞ⧋ āĻĢāĻžāĻ‚āĻļāύ āĻ•āύāĻ¸ā§āĻŸā§āϰāĻžāĻ•ā§āϟāϰāĻĻ⧇āϰ āϜāĻ¨ā§āϝ _āϏāĻŋāύāĻŸā§āϝāĻžāĻ•ā§āϟāĻŋāĻ• āϏ⧁āĻ—āĻžāϰ_āĨ¤ āĻāĻ•āϟāĻŋ āĻĢāĻžāĻ‚āĻļāύ āĻ•āύāĻ¸ā§āĻŸā§āϰāĻžāĻ•ā§āϟāϰ āĻšāĻŋāϏ⧇āĻŦ⧇ `Person` āĻ•ā§āϞāĻžāϏ⧇āϰ āϏāĻŽāϤ⧁āĻ˛ā§āϝ āĻšāĻŦ⧇ āĻāĻŽāύ: ```javascript function Person(name) { @@ -2913,7 +2913,7 @@ function Person(name) { } ``` -Calling a function constructor with `new` results in the creation of an instance of `Person`, `typeof` keyword returns `"object"` for an instance. `typeof member` returns `"object"`. +āĻāĻ•āϟāĻŋ āĻĢāĻžāĻ‚āĻļāύ āĻ•āύāĻ¸ā§āĻŸā§āϰāĻžāĻ•ā§āϟāϰāϕ⧇ `new` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĻāĻŋāϝāĻŧ⧇ āĻ•āϞ āĻ•āϰāĻžāϰ āĻĢāϞ⧇ `Person` āĻāϰ āĻāĻ•āϟāĻŋ āωāĻĻāĻžāĻšāϰāύ/āύāĻŋāĻĻāĻ°ā§āĻļāύ (instance) āϤ⧈āϰāĻŋ āĻšāϝāĻŧ, `typeof` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻāĻ•āϟāĻŋ āχāĻ¨ā§āϏāĻŸā§āϝāĻžāĻ¨ā§āϏ⧇āϰ āϜāĻ¨ā§āϝ `"object"` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤ `typeof member` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `"object"`, āϝ⧇āϟāĻž āϞāĻ— āĻšā§ŸāĨ¤

From beac838386130f8cb2e449c58509fd91755216bb Mon Sep 17 00:00:00 2001 From: iamsaief Date: Fri, 7 Jun 2024 09:10:31 +0600 Subject: [PATCH 07/12] =?UTF-8?q?added=20translation=20till=20100!=20?= =?UTF-8?q?=F0=9F=8E=89=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bn-BD/README_bn-BD.md | 60 ++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/bn-BD/README_bn-BD.md b/bn-BD/README_bn-BD.md index ac3379fe..3a1c2292 100644 --- a/bn-BD/README_bn-BD.md +++ b/bn-BD/README_bn-BD.md @@ -2938,9 +2938,9 @@ console.log(newList.push(5)); #### āωāĻ¤ā§āϤāϰ: D -The `.push` method returns the _new length_ of the array, not the array itself! By setting `newList` equal to `[1, 2, 3].push(4)`, we set `newList` equal to the new length of the array: `4`. +`.push` āĻŽā§‡āĻĨāĻĄ āĻ…ā§āϝāĻžāϰ⧇āϰ āύāϤ⧁āύ āĻĻ⧈āĻ°ā§āĻ˜ā§āϝ āĻĢ⧇āϰāϤ āĻĻ⧇āϝāĻŧ, āĻ…ā§āϝāĻžāϰ⧇āϟāĻŋāϕ⧇ āύāϝāĻŧ! `newList` āϕ⧇ `[1, 2, 3].push(4)` āĻāϰ āϏāĻŽāĻžāύ āϏ⧇āϟ āĻ•āϰāĻžāϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡ āφāĻŽāϰāĻž `newList` āϕ⧇ āĻ…ā§āϝāĻžāϰ⧇āϰ āύāϤ⧁āύ āĻĻ⧈āĻ°ā§āĻ˜ā§āϝ `4` āĻāϰ āϏāĻŽāĻžāύ āĻ•āϰ⧇āĻ›āĻŋāĨ¤ -Then, we try to use the `.push` method on `newList`. Since `newList` is the numerical value `4`, we cannot use the `.push` method: a TypeError is thrown. +āϤāĻžāϰāĻĒāϰ, āφāĻŽāϰāĻž `.push` āĻŽā§‡āĻĨāĻĄāϕ⧇ `newList` āĻ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāĻŋāĨ¤ āϝ⧇āĻšā§‡āϤ⧁ `newList` āĻšāϞ āĻāĻ•āϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻžāĻ—āϤ āĻŽāĻžāύ `4`, āϤāĻžāχ āφāĻŽāϰāĻž `.push` āĻŽā§‡āĻĨāĻĄ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ āύāĻž: āĻāĻ•āϟāĻŋ āϟāĻžāχāĻĒ āĻāϰāϰ (TypeError) āĻĒā§āϰāĻĻāĻ°ā§āĻļāĻŋāϤ āĻšāϝāĻŧāĨ¤

@@ -2971,7 +2971,7 @@ console.log(giveLydiaChocolate.prototype); #### āωāĻ¤ā§āϤāϰ: D -Regular functions, such as the `giveLydiaPizza` function, have a `prototype` property, which is an object (prototype object) with a `constructor` property. Arrow functions however, such as the `giveLydiaChocolate` function, do not have this `prototype` property. `undefined` gets returned when trying to access the `prototype` property using `giveLydiaChocolate.prototype`. +āϏāĻžāϧāĻžāϰāĻŖ āĻĢāĻžāĻ‚āĻļāύāϗ⧁āϞāĻŋāϰ, āϝ⧇āĻŽāύ `giveLydiaPizza` āĻĢāĻžāĻ‚āĻļāύ⧇āϰ, āĻāĻ•āϟāĻŋ `prototype` āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋ āĻĨāĻžāϕ⧇, āϝāĻž āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ (āĻĒā§āϰ⧋āĻŸā§‹āϟāĻžāχāĻĒ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ) āĻāĻŦāĻ‚ āĻāϤ⧇ āĻāĻ•āϟāĻŋ `constructor` āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋ āĻĨāĻžāϕ⧇āĨ¤ āϤāĻŦ⧇, āĻ…ā§āϝāĻžāϰ⧋ āĻĢāĻžāĻ‚āĻļāύāϗ⧁āϞāĻŋāϰ, āϝ⧇āĻŽāύ `giveLydiaChocolate` āĻĢāĻžāĻ‚āĻļāύ⧇āϰ, āĻāχ `prototype` āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋ āĻĨāĻžāϕ⧇ āύāĻžāĨ¤ āϝāĻ–āύ `giveLydiaChocolate.prototype` āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋ āĻ…ā§āϝāĻžāĻ•ā§āϏ⧇āϏ āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāĻž āĻšāϝāĻŧ, āϤāĻ–āύ `undefined` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻž āĻšāϝāĻŧāĨ¤

@@ -3001,14 +3001,15 @@ for (const [x, y] of Object.entries(person)) { #### āωāĻ¤ā§āϤāϰ: A -`Object.entries(person)` returns an array of nested arrays, containing the keys and objects: +`Object.entries(person)` āĻāĻ•āϟāĻŋ āύ⧇āĻ¸ā§āĻŸā§‡āĻĄ āĻ…ā§āϝāĻžāϰ⧇āϰ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇, āϝāĻžāϰ āĻĒā§āϰāϤāĻŋāϟāĻŋ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āĻŸā§‡ āĻĨāĻžāϕ⧇ āϕ⧀ āĻāĻŦāĻ‚ āĻ­ā§āϝāĻžāϞ⧁: `[ [ 'name', 'Lydia' ], [ 'age', 21 ] ]` -Using the `for-of` loop, we can iterate over each element in the array, the subarrays in this case. We can destructure the subarrays instantly in the for-of loop, using `const [x, y]`. `x` is equal to the first element in the subarray, `y` is equal to the second element in the subarray. +`for-of` āϞ⧁āĻĒ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇, āφāĻŽāϰāĻž āĻ…ā§āϝāĻžāϰ⧇āϰ āĻĒā§āϰāϤāĻŋāϟāĻŋ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ, āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ āϏāĻžāĻŦāĻ…ā§āϝāĻžāϰ⧇āϗ⧁āϞāĻŋ, āϤ⧇ āχāϟāĻžāϰ⧇āϟ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ āφāĻŽāϰāĻž `for-of` āϞ⧁āĻĒ⧇ āϏāĻžāĻŦāĻ…ā§āϝāĻžāϰ⧇āϗ⧁āϞāĻŋāϕ⧇ āϏāĻžāĻĨ⧇ āϏāĻžāĻĨ⧇ āĻĄāĻŋāĻ¸ā§āĻŸā§āϰāĻžāĻ•āϚāĻžāϰ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ, `const [x, y]` āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇āĨ¤ `x` āϏāĻžāĻŦāĻ…ā§āϝāĻžāϰ⧇āϰ āĻĒā§āϰāĻĨāĻŽ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āϏāĻŽāĻžāύ āĻšāϝāĻŧ, `y` āϏāĻžāĻŦāĻ…ā§āϝāĻžāϰ⧇āϰ āĻĻā§āĻŦāĻŋāϤ⧀āϝāĻŧ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āϏāĻŽāĻžāύ āĻšāϝāĻŧāĨ¤ -The first subarray is `[ "name", "Lydia" ]`, with `x` equal to `"name"`, and `y` equal to `"Lydia"`, which get logged. -The second subarray is `[ "age", 21 ]`, with `x` equal to `"age"`, and `y` equal to `21`, which get logged. +āĻĒā§āϰāĻĨāĻŽ āϏāĻžāĻŦāĻ…ā§āϝāĻžāϰ⧇ `[ "name", "Lydia" ]`, āϝ⧇āĻ–āĻžāύ⧇ `x` `"name"` āĻāϰ āϏāĻŽāĻžāύ āĻāĻŦāĻ‚ `y` `"Lydia"` āĻāϰ āϏāĻŽāĻžāύ, āϝāĻž āϞāĻ— āĻ•āϰāĻž āĻšāϝāĻŧāĨ¤ + +āĻĻā§āĻŦāĻŋāϤ⧀āϝāĻŧ āϏāĻžāĻŦāĻ…ā§āϝāĻžāϰ⧇ `[ "age", 21 ]`, āϝ⧇āĻ–āĻžāύ⧇ `x` `"age"` āĻāϰ āϏāĻŽāĻžāύ āĻāĻŦāĻ‚ `y` `21` āĻāϰ āϏāĻŽāĻžāύ, āϝāĻž āϞāĻ— āĻ•āϰāĻž āĻšāϝāĻŧāĨ¤

@@ -3035,7 +3036,7 @@ getItems(["banana", "apple"], "pear", "orange") #### āωāĻ¤ā§āϤāϰ: D -`...args` is a rest parameter. The rest parameter's value is an array containing all remaining arguments, **and can only be the last parameter**! In this example, the rest parameter was the second parameter. This is not possible, and will throw a syntax error. +`...args` āĻšāϞ āĻāĻ•āϟāĻŋ āϰ⧇āĻ¸ā§āϟ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰāĨ¤ āϰ⧇āĻ¸ā§āϟ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ⧇āϰ āĻŽāĻžāύ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇ āĻšāϝāĻŧ āϝāĻž āϏāĻŽāĻ¸ā§āϤ āĻ…āĻŦāĻļāĻŋāĻˇā§āϟ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āϧāĻžāϰāĻŖ āĻ•āϰ⧇, **āĻāĻŦāĻ‚ āĻāϟāĻŋ āĻļ⧁āϧ⧁āĻŽāĻžāĻ¤ā§āϰ āĻļ⧇āώ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ āĻšāϤ⧇ āĻĒāĻžāϰ⧇**! āĻāχ āωāĻĻāĻžāĻšāϰāϪ⧇, āϰ⧇āĻ¸ā§āϟ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰāϟāĻŋ āĻĻā§āĻŦāĻŋāϤ⧀āϝāĻŧ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ āĻ›āĻŋāϞāĨ¤ āĻāϟāĻŋ āϏāĻŽā§āĻ­āĻŦ āύāϝāĻŧ āĻāĻŦāĻ‚ āĻāĻ•āϟāĻŋ āϏāĻŋāύāĻŸā§āϝāĻžāĻ•ā§āϏ āĻāϰāϰ āϘāϟāĻžāĻŦ⧇āĨ¤ ```javascript function getItems(fruitList, favoriteFruit, ...args) { @@ -3045,7 +3046,7 @@ function getItems(fruitList, favoriteFruit, ...args) { getItems(['banana', 'apple'], 'pear', 'orange'); ``` -The above example works. This returns the array `[ 'banana', 'apple', 'orange', 'pear' ]` +āωāĻĒāϰ⧇āϰ āωāĻĻāĻžāĻšāϰāĻŖāϟāĻŋ āϏāĻ āĻŋāĻ•āĻ­āĻžāĻŦ⧇ āĻ•āĻžāϜ āĻ•āϰ⧇āĨ¤ āĻāϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇ `[ 'banana', 'apple', 'orange', 'pear' ]` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ āĻĻ⧇āϝāĻŧāĨ¤

@@ -3076,16 +3077,16 @@ console.log(nums(1, 2)); #### āωāĻ¤ā§āϤāϰ: B -In JavaScript, we don't _have_ to write the semicolon (`;`) explicitly, however the JavaScript engine still adds them after statements. This is called **Automatic Semicolon Insertion**. A statement can for example be variables, or keywords like `throw`, `return`, `break`, etc. +āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āĻŸā§‡, āφāĻŽāĻžāĻĻ⧇āϰ āĻ¸ā§āĻĒāĻˇā§āϟāĻ­āĻžāĻŦ⧇ āϏ⧇āĻŽāĻŋāϕ⧋āϞāύ (`;`) _āύāĻž āϞāĻŋāĻ–āϞ⧇ āĻšāĻŦ⧇_, āϤāĻŦ⧇ āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āχāĻžā§āϜāĻŋāύāχ āĻ¸ā§āĻŸā§‡āϟāĻŽā§āϝāĻžāĻ¨ā§āĻŸā§‡āϰ āĻĒāϰ⧇ āϏ⧇āϗ⧁āϞāĻŋ āϝ⧋āĻ— āĻ•āϰ⧇ āĻĻā§‡ā§ŸāĨ¤ āĻāϟāĻŋāϕ⧇ **āĻ¸ā§āĻŦāϝāĻŧāĻ‚āĻ•ā§āϰāĻŋāϝāĻŧ āϏ⧇āĻŽāĻŋāϕ⧋āϞāύ āϏāĻ‚āϝ⧋āϜāύ** (Automatic Semicolon Insertion) āĻŦāϞāĻž āĻšāϝāĻŧāĨ¤ āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§‡āϟāĻŽā§āϝāĻžāĻ¨ā§āϟ āĻšāϤ⧇ āĻĒāĻžāϰ⧇ āωāĻĻāĻžāĻšāϰāĻŖāĻ¸ā§āĻŦāϰ⧂āĻĒ āϭ⧇āϰāĻŋāϝāĻŧ⧇āĻŦāϞāϗ⧁āϞāĻŋ, āĻŦāĻž āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āϝ⧇āĻŽāύ `throw`, `return`, `break`, āχāĻ¤ā§āϝāĻžāĻĻāĻŋāĨ¤ -Here, we wrote a `return` statement, and another value `a + b` on a _new line_. However, since it's a new line, the engine doesn't know that it's actually the value that we wanted to return. Instead, it automatically added a semicolon after `return`. You could see this as: +āĻāĻ–āĻžāύ⧇, āφāĻŽāϰāĻž āĻāĻ•āϟāĻŋ `return` āĻ¸ā§āĻŸā§‡āϟāĻŽā§āϝāĻžāĻ¨ā§āĻŸā§‡āϰ āϞāĻŋāϖ⧇āĻ›āĻŋ, āĻāĻŦāĻ‚ āφāϰ⧇āĻ•āϟāĻŋ āĻŽāĻžāύ `a + b` āĻāĻ•āϟāĻŋ _āύāϤ⧁āύ āϞāĻžāχāύ⧇_āĨ¤ āϤāĻŦ⧇, āϝ⧇āĻšā§‡āϤ⧁ āĻāϟāĻŋ āĻāĻ•āϟāĻŋ āύāϤ⧁āύ āϞāĻžāχāύ, āχāĻžā§āϜāĻŋāύ āϜāĻžāύ⧇ āύāĻž āϝ⧇ āĻāϟāĻŋ āφāϏāϞ⧇ āϏ⧇āχ āĻŽāĻžāύ āϝāĻž āφāĻŽāϰāĻž āĻĢ⧇āϰāϤ āĻĻāĻŋāϤ⧇ āĻšā§‡āϝāĻŧ⧇āĻ›āĻŋāϞāĻžāĻŽāĨ¤ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤ⧇, āĻāϟāĻŋ āĻ¸ā§āĻŦāϝāĻŧāĻ‚āĻ•ā§āϰāĻŋāϝāĻŧāĻ­āĻžāĻŦ⧇ `return` āĻāϰ āĻĒāϰ⧇ āĻāĻ•āϟāĻŋ āϏ⧇āĻŽāĻŋāϕ⧋āϞāύ āϝ⧋āĻ— āĻ•āϰ⧇āϛ⧇āĨ¤ āφāĻĒāύāĻŋ āĻāϰāĻ•āĻŽ āĻ­āĻžāĻŦāϤ⧇ āĻĒāĻžāϰ⧇āύ: ```javascript return; a + b; ``` -This means that `a + b` is never reached, since a function stops running after the `return` keyword. If no value gets returned, like here, the function returns `undefined`. Note that there is no automatic insertion after `if/else` statements! +āĻāϰ āĻŽāĻžāύ⧇ āĻšāϞ āϝ⧇ `a + b`-āϤ⧇ āĻ•āĻ–āύāχ āĻĒ⧌āρāĻ›āĻžāύ⧋ āĻšāϝāĻŧ āύāĻž, āĻ•āĻžāϰāĻŖ āĻāĻ•āϟāĻŋ āĻĢāĻžāĻ‚āĻļāύ `return` āϕ⧀āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄā§‡āϰ āĻĒāϰ⧇ āϚāϞāĻž āĻŦāĻ¨ā§āϧ āĻ•āϰ⧇ āĻĻ⧇āϝāĻŧāĨ¤ āϝāĻĻāĻŋ āϕ⧋āύāĻ“ āĻŽāĻžāύ āϰāĻŋāϟāĻžāĻ°ā§āύ āύāĻž āĻ•āϰāĻž āĻšāϝāĻŧ, āϝ⧇āĻŽāύ āĻāĻ–āĻžāύ⧇, āĻĢāĻžāĻ‚āĻļāύ `undefined` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤ āϞāĻ•ā§āĻˇā§āϝ āĻ•āϰāĻŦ⧇āύ āϝ⧇ `if/else` āĻ¸ā§āĻŸā§‡āϟāĻŽā§āϝāĻžāĻ¨ā§āĻŸā§‡āϰ āĻĒāϰ⧇ āϕ⧋āύāĻ“ āĻ¸ā§āĻŦāϝāĻŧāĻ‚āĻ•ā§āϰāĻŋāϝāĻŧ āϏāĻ‚āϝ⧋āϜāύ āύ⧇āχ!

@@ -3121,7 +3122,7 @@ console.log(member.name); #### āωāĻ¤ā§āϤāϰ: B -We can set classes equal to other classes/function constructors. In this case, we set `Person` equal to `AnotherPerson`. The name on this constructor is `Sarah`, so the name property on the new `Person` instance `member` is `"Sarah"`. +āφāĻŽāϰāĻž āĻ•ā§āϞāĻžāϏāϗ⧁āϞāĻŋāϕ⧇ āĻ…āĻ¨ā§āϝ āĻ•ā§āϞāĻžāϏ/āĻĢāĻžāĻ‚āĻļāύ āĻ•āύāĻ¸ā§āĻŸā§āϰāĻžāĻ•ā§āϟāϰ⧇āϰ āϏāĻŽāĻžāύ āϏ⧇āϟ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āφāĻŽāϰāĻž `Person`-āϕ⧇ `AnotherPerson` āĻāϰ āϏāĻŽāĻžāύ āĻ•āϰ⧇āĻ›āĻŋāĨ¤ āĻāχ āĻ•āύāĻ¸ā§āĻŸā§āϰāĻžāĻ•ā§āϟāϰ⧇āϰ āύāĻžāĻŽ `Sarah`, āϤāĻžāχ āύāϤ⧁āύ `Person` āχāύāĻ¸ā§āĻŸā§āϝāĻžāĻ¨ā§āϏ `member` āĻāϰ name āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋ `"Sarah"` āĻšāĻŦ⧇āĨ¤

@@ -3149,9 +3150,9 @@ console.log(Object.keys(info)); #### āωāĻ¤ā§āϤāϰ: D -A Symbol is not _enumerable_. The Object.keys method returns all _enumerable_ key properties on an object. The Symbol won't be visible, and an empty array is returned. When logging the entire object, all properties will be visible, even non-enumerable ones. +āĻāĻ•āϟāĻŋ Symbol _enumerable_ āύāϝāĻŧāĨ¤ Object.keys āĻŽā§‡āĻĨāĻĄ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϏāĻŽāĻ¸ā§āϤ _enumerable_ āϕ⧀ āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋāϗ⧁āϞāĻŋ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤ Symbol āĻĻ⧃āĻļā§āϝāĻŽāĻžāύ āĻšāĻŦ⧇ āύāĻž, āĻāĻŦāĻ‚ āĻāĻ•āϟāĻŋ āĻ–āĻžāϞāĻŋ āĻ…ā§āϝāĻžāϰ⧇ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤ āĻĒ⧁āϰ⧋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϟāĻŋ āϞāĻ— āĻ•āϰāϞ⧇, āϏāĻŽāĻ¸ā§āϤ āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋ āĻĻ⧃āĻļā§āϝāĻŽāĻžāύ āĻšāĻŦ⧇, āĻāĻŽāύāĻ•āĻŋ non-enumerable āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋāϗ⧁āϞāĻŋāĻ“āĨ¤ -This is one of the many qualities of a symbol: besides representing an entirely unique value (which prevents accidental name collision on objects, for example when working with 2 libraries that want to add properties to the same object), you can also "hide" properties on objects this way (although not entirely. You can still access symbols using the `Object.getOwnPropertySymbols()` method). +āĻāϟāĻŋ āĻāĻ•āϟāĻŋ Symbol āĻāϰ āĻ…āύ⧇āĻ• āϗ⧁āĻŖāĻžāĻŦāϞ⧀āϰ āĻŽāĻ§ā§āϝ⧇ āĻāĻ•āϟāĻŋ: āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖ āĻ…āύāĻ¨ā§āϝ āĻŽāĻžāύ āωāĻĒāĻ¸ā§āĻĨāĻžāĻĒāύ āĻ•āϰāĻžāϰ āĻĒāĻžāĻļāĻžāĻĒāĻžāĻļāĻŋ (āϝāĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϗ⧁āϞāĻŋāϤ⧇ āφāĻ•āĻ¸ā§āĻŽāĻŋāĻ• āύāĻžāĻŽ āϏāĻ‚āϘāĻ°ā§āώ āĻĒā§āϰāϤāĻŋāϰ⧋āϧ āĻ•āϰ⧇, āωāĻĻāĻžāĻšāϰāĻŖāĻ¸ā§āĻŦāϰ⧂āĻĒ āϝāĻ–āύ āĻĻ⧁āϟāĻŋ āϞāĻžāχāĻŦā§āϰ⧇āϰāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āĻāĻ•āχ āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋ āϝ⧋āĻ— āĻ•āϰāϤ⧇ āϚāĻžāϝāĻŧ), āφāĻĒāύāĻŋ āĻāχ āωāĻĒāĻžāϝāĻŧ⧇ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϗ⧁āϞāĻŋāϤ⧇ āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋāϗ⧁āϞāĻŋ "āϞ⧁āĻ•āĻžāϤ⧇" āĻĒāĻžāϰ⧇āύ (āϝāĻĻāĻŋāĻ“ āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖāϰ⧂āĻĒ⧇ āύāϝāĻŧāĨ¤ āφāĻĒāύāĻŋ āĻāĻ–āύāĻ“ `Object.getOwnPropertySymbols()` āĻŽā§‡āĻĨāĻĄ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ Symbol āϗ⧁āϞāĻŋāϤ⧇ āĻ…ā§āϝāĻžāĻ•ā§āϏ⧇āϏ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āύ)āĨ¤

@@ -3181,15 +3182,15 @@ console.log(getUser(user)) #### āωāĻ¤ā§āϤāϰ: A -The `getList` function receives an array as its argument. Between the parentheses of the `getList` function, we destructure this array right away. You could see this as: +`getList` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āĻšāĻŋāϏāĻžāĻŦ⧇ āĻ—ā§āϰāĻšāĻŖ āĻ•āϰ⧇āĨ¤ `getList` āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āĻŦāĻ¨ā§āϧāύ⧀āϰ āĻŽāĻ§ā§āϝ⧇, āφāĻŽāϰāĻž āĻāχ āĻ…ā§āϝāĻžāϰ⧇āϟāĻŋ āϏāĻžāĻĨ⧇ āϏāĻžāĻĨ⧇ āĻĄāĻŋāĻ¸ā§āĻŸā§āϰāĻžāĻ•āϚāĻžāϰ āĻ•āϰāĻŋāĨ¤ āφāĻĒāύāĻŋ āĻāϟāĻŋ āĻāĻ­āĻžāĻŦ⧇ āĻĻ⧇āĻ–āϤ⧇ āĻĒāĻžāϰ⧇āύ: `[x, ...y] = [1, 2, 3, 4]` -With the rest parameter `...y`, we put all "remaining" arguments in an array. The remaining arguments are `2`, `3` and `4` in this case. The value of `y` is an array, containing all the rest parameters. The value of `x` is equal to `1` in this case, so when we log `[x, y]`, `[1, [2, 3, 4]]` gets logged. +āϰ⧇āĻ¸ā§āϟ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ `...y` āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇, āφāĻŽāϰāĻž āϏāĻŽāĻ¸ā§āϤ "āĻ…āĻŦāĻļāĻŋāĻˇā§āϟ" āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟāϗ⧁āϞāĻŋāϕ⧇ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇āϤ⧇ āϰāĻžāĻ–āĻŋāĨ¤ āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ āĻ…āĻŦāĻļāĻŋāĻˇā§āϟ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟāϗ⧁āϞāĻŋ āĻšāϞ `2`, `3` āĻāĻŦāĻ‚ `4`āĨ¤ `y` āĻāϰ āĻŽāĻžāύ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇, āϝāĻž āϏāĻŽāĻ¸ā§āϤ āϰ⧇āĻ¸ā§āϟ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ āϧāĻžāϰāĻŖ āĻ•āϰ⧇āĨ¤ `x` āĻāϰ āĻŽāĻžāύ āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ `1`, āϤāĻžāχ āϝāĻ–āύ āφāĻŽāϰāĻž `[x, y]` āϞāĻ— āĻ•āϰāĻŋ, āϤāĻ–āύ `[1, [2, 3, 4]]` āϞāĻ— āĻšāϝāĻŧāĨ¤ -The `getUser` function receives an object. With arrow functions, we don't _have_ to write curly brackets if we just return one value. However, if you want to instantly return an _object_ from an arrow function, you have to write it between parentheses, otherwise everything between the two braces will be interpreted as a block statement. In this case the code between the braces is not a valid JavaScript code, so a `SyntaxError` gets thrown. +`getUser` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻ—ā§āϰāĻšāĻŖ āĻ•āϰ⧇āĨ¤ āĻ…ā§āϝāĻžāϰ⧋ āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āφāĻŽāϰāĻž āϝāĻĻāĻŋ āϕ⧇āĻŦāϞ āĻāĻ•āϟāĻŋ āĻŽāĻžāύ āĻĢ⧇āϰāϤ āĻĻāĻŋāϤ⧇ āϚāĻžāχ āϤāĻŦ⧇ āφāĻŽāĻžāĻĻ⧇āϰ āĻ•āĻžāĻ°ā§āϞāĻŋ āĻŦā§āĻ°ā§āϝāĻžāϕ⧇āϟ āϞāĻŋāĻ–āϤ⧇ _āĻšāĻŦ⧇ āύāĻž_āĨ¤ āϤāĻŦ⧇, āϝāĻĻāĻŋ āφāĻĒāύāĻŋ āĻ…ā§āϝāĻžāϰ⧋ āĻĢāĻžāĻ‚āĻļāύ āĻĨ⧇āϕ⧇ āϏāĻžāĻĨ⧇ āϏāĻžāĻĨ⧇ āĻāĻ•āϟāĻŋ _āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ_ āĻĢ⧇āϰāϤ āĻĻāĻŋāϤ⧇ āϚāĻžāύ, āϤāĻŦ⧇ āφāĻĒāύāĻžāϕ⧇ āĻāϟāĻŋ āĻŦāĻ¨ā§āϧāύ⧀āϰ āĻŽāĻ§ā§āϝ⧇ āϞāĻŋāĻ–āϤ⧇ āĻšāĻŦ⧇, āĻ…āĻ¨ā§āϝāĻĨāĻžāϝāĻŧ āĻĻ⧁āϟāĻŋ āĻŦā§āϰ⧇āϏ⧇āϰ āĻŽāĻ§ā§āϝ⧇ āĻĨāĻžāĻ•āĻž āϏāĻŦāĻ•āĻŋāϛ⧁ āĻāĻ•āϟāĻŋ āĻŦā§āϞāĻ• āĻ¸ā§āĻŸā§‡āϟāĻŽā§‡āĻ¨ā§āϟ āĻšāĻŋāϏāĻžāĻŦ⧇ āĻ—āĻŖā§āϝ āĻ•āϰāĻž āĻšāĻŦ⧇āĨ¤ āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ āĻŦā§āϰ⧇āϏ⧇āϰ āĻŽāĻ§ā§āϝ⧇ āĻĨāĻžāĻ•āĻž āϕ⧋āĻĄāϟāĻŋ āĻāĻ•āϟāĻŋ āĻŦ⧈āϧ āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āϕ⧋āĻĄ āύāϝāĻŧ, āϤāĻžāχ āĻāĻ•āϟāĻŋ `SyntaxError` āĻĒā§āϰāĻĻāĻ°ā§āĻļāĻŋāϤ āĻšāϝāĻŧāĨ¤ -The following function would have returned an object: +āύāĻŋāĻŽā§āύāϞāĻŋāĻ–āĻŋāϤ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻĢ⧇āϰāϤ āĻĻāĻŋāϤ: `const getUser = user => ({ name: user.name, age: user.age })` @@ -3216,19 +3217,20 @@ console.log(name()); #### āωāĻ¤ā§āϤāϰ: C -The variable `name` holds the value of a string, which is not a function, and thus cannot be invoked. +āϭ⧇āϰāĻŋāϝāĻŧ⧇āĻŦāϞ `name` āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻŽāĻžāύ āϧāĻžāϰāĻŖ āĻ•āϰ⧇, āϝāĻž āĻāĻ•āϟāĻŋ āĻĢāĻžāĻ‚āĻļāύ āύāϝāĻŧ, āĻāĻŦāĻ‚ āϤāĻžāχ āĻāϟāĻŋ āχāύāĻ­ā§‹āĻ• (āĻ•āϞ) āĻ•āϰāĻž āϏāĻŽā§āĻ­āĻŦ āύāϝāĻŧāĨ¤ + +`TypeErrors` āϤāĻ–āύ āĻĒā§āϰāĻĻāĻ°ā§āĻļāĻŋāϤ āĻšāϝāĻŧ āϝāĻ–āύ āϕ⧋āύāĻ“ āĻŽāĻžāύ āĻĒā§āϰāĻ¤ā§āϝāĻžāĻļāĻŋāϤ āϟāĻžāχāĻĒ⧇āϰ āύāĻž āĻšāϝāĻŧāĨ¤ āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āφāĻļāĻž āĻ•āϰ⧇āĻ›āĻŋāϞ āϝ⧇ `name` āĻāĻ•āϟāĻŋ āĻĢāĻžāĻ‚āĻļāύ āĻšāĻŦ⧇ āĻ•āĻžāϰāĻŖ āφāĻŽāϰāĻž āĻāϟāĻŋ āχāύāĻ­ā§‹āĻ• āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāĻ›āĻŋāĨ¤ āĻ•āĻŋāĻ¨ā§āϤ⧁ āĻāϟāĻŋ āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻ›āĻŋāϞ, āϤāĻžāχ āĻāĻ•āϟāĻŋ TypeError āĻĒā§āϰāĻĻāĻ°ā§āĻļāĻŋāϤ āĻšāϝāĻŧ: name is not a function! -TypeErrors get thrown when a value is not of the expected type. JavaScript expected `name` to be a function since we're trying to invoke it. It was a string however, so a TypeError gets thrown: name is not a function! +`SyntaxErrors` āϤāĻ–āύ āĻĒā§āϰāĻĻāĻ°ā§āĻļāĻŋāϤ āĻšāϝāĻŧ āϝāĻ–āύ āφāĻĒāύāĻŋ āĻāĻŽāύ āĻ•āĻŋāϛ⧁ āϞāĻŋāϖ⧇āϛ⧇āύ āϝāĻž āĻŦ⧈āϧ āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āύāϝāĻŧ, āωāĻĻāĻžāĻšāϰāĻŖāĻ¸ā§āĻŦāϰ⧂āĻĒ āϝāĻ–āύ āφāĻĒāύāĻŋ `return` āĻļāĻŦā§āĻĻāϟāĻŋāϕ⧇ `retrun` āĻšāĻŋāϏāĻžāĻŦ⧇ āϞāĻŋāϖ⧇āϛ⧇āύāĨ¤ -SyntaxErrors get thrown when you've written something that isn't valid JavaScript, for example when you've written the word `return` as `retrun`. -ReferenceErrors get thrown when JavaScript isn't able to find a reference to a value that you're trying to access. +`ReferenceErrors` āϤāĻ–āύ āĻĒā§āϰāĻĻāĻ°ā§āĻļāĻŋāϤ āĻšāϝāĻŧ āϝāĻ–āύ āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āϏ⧇āχ āĻŽāĻžāύāϟāĻŋāϰ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āϖ⧁āρāĻœā§‡ āĻĒāĻžāϝāĻŧ āύāĻž āϝāĻž āφāĻĒāύāĻŋ āĻ…ā§āϝāĻžāĻ•ā§āϏ⧇āϏ āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāϛ⧇āύāĨ¤

--- -###### 100. What's the value of output? +###### 100. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āĻŸā§‡āϰ āĻ­ā§āϝāĻžāϞ⧁ āĻ•āĻŋ? ```javascript // 🎉✨ This is my 100th question! ✨🎉 @@ -3247,16 +3249,16 @@ You should${'' && `n't`} see a therapist after so much JavaScript lol`; #### āωāĻ¤ā§āϤāϰ: B -`[]` is a truthy value. With the `&&` operator, the right-hand value will be returned if the left-hand value is a truthy value. In this case, the left-hand value `[]` is a truthy value, so `"Im'` gets returned. +`[]` āĻāĻ•āϟāĻŋ truthy āĻŽāĻžāύāĨ¤ `&&` āĻ…āĻĒāĻžāϰ⧇āϟāϰ⧇āϰ āϏāĻžāĻĨ⧇, āĻŦāĻžāĻŽ āĻĒāĻžāĻļ⧇āϰ āĻŽāĻžāύ āϝāĻĻāĻŋ āĻāĻ•āϟāĻŋ truthy āĻŽāĻžāύ āĻšāϝāĻŧ, āϤāĻžāĻšāϞ⧇ āĻĄāĻžāύ āĻĒāĻžāĻļ⧇āϰ āĻŽāĻžāύāϟāĻŋ āĻĢ⧇āϰāϤ āĻĻ⧇āĻ“āϝāĻŧāĻž āĻšāĻŦ⧇āĨ¤ āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āĻŦāĻžāĻŽ āĻĒāĻžāĻļ⧇āϰ āĻŽāĻžāύ `[]` āĻāĻ•āϟāĻŋ truthy āĻŽāĻžāύ, āϤāĻžāχ `"I'm"` āĻĢ⧇āϰāϤ āĻĻ⧇āĻ“āϝāĻŧāĻž āĻšāϝāĻŧāĨ¤ -`""` is a falsy value. If the left-hand value is falsy, nothing gets returned. `n't` doesn't get returned. +`""` āĻāĻ•āϟāĻŋ falsy āĻŽāĻžāύāĨ¤ āϝāĻĻāĻŋ āĻŦāĻžāĻŽ āĻĒāĻžāĻļ⧇āϰ āĻŽāĻžāύ falsy āĻšāϝāĻŧ, āϤāĻžāĻšāϞ⧇ āĻ•āĻŋāϛ⧁āχ āĻĢ⧇āϰāϤ āĻĻ⧇āĻ“āϝāĻŧāĻž āĻšāϝāĻŧ āύāĻžāĨ¤ `n't` āĻĢ⧇āϰāϤ āĻĻ⧇āĻ“āϝāĻŧāĻž āĻšāϝāĻŧ āύāĻžāĨ¤

--- -###### 101. What's the value of output? +###### 101. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āĻŸā§‡āϰ āĻ­ā§āϝāĻžāϞ⧁ āĻ•āĻŋ? ```javascript const one = false || {} || null; @@ -3289,7 +3291,7 @@ With the `||` operator, we can return the first truthy operand. If all values ar --- -###### 102. What's the value of output? +###### 102. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āĻŸā§‡āϰ āĻ­ā§āϝāĻžāϞ⧁ āĻ•āĻŋ? ```javascript const myPromise = () => Promise.resolve('I have resolved!'); @@ -3333,7 +3335,7 @@ This means that it waited for the `myPromise` to resolve with the value `I have --- -###### 103. What's the value of output? +###### 103. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āĻŸā§‡āϰ āĻ­ā§āϝāĻžāϞ⧁ āĻ•āĻŋ? ```javascript const set = new Set(); From 917bb1b21952b8bae36defc263b3df2b2b6f177f Mon Sep 17 00:00:00 2001 From: iamsaief Date: Sun, 9 Jun 2024 06:48:56 +0600 Subject: [PATCH 08/12] added translation till 112 --- bn-BD/README_bn-BD.md | 84 +++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/bn-BD/README_bn-BD.md b/bn-BD/README_bn-BD.md index 3a1c2292..fb94bcef 100644 --- a/bn-BD/README_bn-BD.md +++ b/bn-BD/README_bn-BD.md @@ -499,7 +499,7 @@ sum(1, '2'); #### āωāĻ¤ā§āϤāϰ: C -āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āĻāĻ•āϟāĻŋ **āĻĄāĻžā§ŸāύāĻžāĻŽāĻŋāĻ• āϟāĻžāχāĻĒ āĻ­āĻžāώāĻžāσ** āφāĻŽāϰāĻž āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞ⧇āϰ āϟāĻžāχāĻĒ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻ•āϰāĻŋ āύāĻžāĨ¤ āφāĻĒāύāĻŋ āϜāĻžāύāϤ⧇ āĻĒāĻžāϰ⧇āύ āύāĻž āĻ­ā§āϝāĻžāϞ⧁ āĻ¸ā§āĻŦ⧟āĻ‚āĻ•ā§āϰāĻŋ⧟āĻ­āĻžāĻŦ⧇āχ āĻāĻ• āϟāĻžāχāĻĒ āĻĨ⧇āϕ⧇ āĻ…āĻ¨ā§āϝ āϟāĻžāχāĻĒ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻšā§Ÿā§‡ āϝāĻžā§Ÿ, āϝ⧇āϟāĻžāϕ⧇ āĻŦāϞāĻž āĻšā§Ÿ **āĻ•ā§‹ā§ŸāĻžāĻ°ā§āĻļāύ (coercion)**āĨ¤ āĻāϟāĻž āĻšāϞ āĻāĻ• āϟāĻžāχāĻĒ āĻĨ⧇āϕ⧇ āĻ…āĻ¨ā§āϝ āϟāĻžāχāĻĒ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻšāĻ“ā§ŸāĻžāĨ¤ +āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āĻāĻ•āϟāĻŋ **āĻĄāĻžā§ŸāύāĻžāĻŽāĻŋāĻ• āϟāĻžāχāĻĒ āĻ­āĻžāώāĻžāσ** āφāĻŽāϰāĻž āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞ⧇āϰ āϟāĻžāχāĻĒ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻ•āϰāĻŋ āύāĻžāĨ¤ āφāĻĒāύāĻŋ āϜāĻžāύāϤ⧇ āĻĒāĻžāϰ⧇āύ āύāĻž āĻ­ā§āϝāĻžāϞ⧁ āĻ¸ā§āĻŦ⧟āĻ‚āĻ•ā§āϰāĻŋ⧟āĻ­āĻžāĻŦ⧇āχ āĻāĻ• āϟāĻžāχāĻĒ āĻĨ⧇āϕ⧇ āĻ…āĻ¨ā§āϝ āϟāĻžāχāĻĒ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻšā§Ÿā§‡ āϝāĻžā§Ÿ, āϝ⧇āϟāĻžāϕ⧇ āĻŦāϞāĻž āĻšā§Ÿ **āĻ•ā§‹ā§ŸāĻžāĻ°ā§āĻļāύ [coercion](<(coercion)[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#type_coercion]>)**āĨ¤ āĻāϟāĻž āĻšāϞ āĻāĻ• āϟāĻžāχāĻĒ āĻĨ⧇āϕ⧇ āĻ…āĻ¨ā§āϝ āϟāĻžāχāĻĒ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻšāĻ“ā§ŸāĻžāĨ¤ āĻāχ āωāĻĻāĻžāĻšāϰāύ⧇, āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āĻāχ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋāϕ⧇ āϝ⧁āĻ•ā§āϤāĻŋāϏāĻ™ā§āĻ—āϤ āĻ“ āĻāϰ āĻāĻ•āϟāĻŋ āĻĢāϞāĻžāĻĢāϞ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ `1` āύāĻžāĻŽā§āĻŦāĻžāϰāϟāĻŋāϕ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇āϛ⧇āĨ¤ āύāĻžāĻŽā§āĻŦāĻžāϰ `1` āĻ“ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ `"2"` āĻāϰ āϝ⧋āϗ⧇āϰ āĻŦ⧇āϞāĻžā§Ÿ āύāĻžāĻŽā§āĻŦāĻžāϰāϟāĻŋāϕ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻšāĻŋāϏ⧇āĻŦ⧇ āϧāϰāĻž āĻšā§Ÿā§‡āϛ⧇āĨ¤ āφāĻŽāϰāĻž āĻĻ⧁āĻŸā§‹ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āϕ⧇ āϝ⧁āĻ•ā§āϤ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ āĻāĻ­āĻžāĻŦ⧇, `"Hello" + "World"`, āϤāĻžāχ āĻāĻ–āĻžāύ⧇ `"1" + "2"` āĻĢāϞāĻžāĻĢāϞ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇ `"12"`āĨ¤ @@ -3278,13 +3278,13 @@ console.log(one, two, three); #### āωāĻ¤ā§āϤāϰ: C -With the `||` operator, we can return the first truthy operand. If all values are falsy, the last operand gets returned. +`||` āĻ…āĻĒāĻžāϰ⧇āϟāϰ⧇āϰ āϏāĻžāĻšāĻžāĻ¯ā§āϝ⧇, āφāĻŽāϰāĻž **āĻĒā§āϰāĻĨāĻŽ āϏāĻ¤ā§āϝ āĻ…āĻĒāĻžāϰ⧇āĻ¨ā§āĻĄāϟāĻŋ** āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻžāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ āϝāĻĻāĻŋ āϏāĻŽāĻ¸ā§āϤ āĻŽāĻžāύ āĻŽāĻŋāĻĨā§āϝāĻž āĻšāϝāĻŧ, **āĻļ⧇āώ āĻ…āĻĒāĻžāϰ⧇āĻ¨ā§āĻĄāϟāĻŋ** āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤ -`(false || {} || null)`: the empty object `{}` is a truthy value. This is the first (and only) truthy value, which gets returned. `one` is equal to `{}`. +`(false || {} || null)`: āĻ–āĻžāϞāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ `{}` āĻāĻ•āϟāĻŋ āϏāĻ¤ā§āϝ āĻŽāĻžāύāĨ¤ āĻāϟāĻŋ āĻĒā§āϰāĻĨāĻŽ (āĻāĻŦāĻ‚ āĻāĻ•āĻŽāĻžāĻ¤ā§āϰ) āϏāĻ¤ā§āϝ āĻŽāĻžāύ, āϝāĻž āϰāĻŋāϟāĻžāĻ°ā§āύ āĻšā§ŸāĨ¤ `one` āϏāĻŽāĻžāύ `{}`āĨ¤ -`(null || false || "")`: all operands are falsy values. This means that the last operand, `""` gets returned. `two` is equal to `""`. +`(null || false || "")`: āϏāĻŽāĻ¸ā§āϤ āĻ…āĻĒāĻžāϰ⧇āĻ¨ā§āĻĄ āĻŽāĻŋāĻĨā§āϝāĻž āĻŽāĻžāύāĨ¤ āĻāϰ āĻŽāĻžāύ⧇ āĻšāϞ āĻļ⧇āώ āĻ…āĻĒāĻžāϰ⧇āĻ¨ā§āĻĄ, `""` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻž āĻšāϝāĻŧāĨ¤ `two` āϏāĻŽāĻžāύ `""`āĨ¤ -`([] || 0 || "")`: the empty array`[]` is a truthy value. This is the first truthy value, which gets returned. `three` is equal to `[]`. +`([] || 0 || "")`: āĻ–āĻžāϞāĻŋ āĻ…ā§āϝāĻžāϰ⧇`[]` āĻāĻ•āϟāĻŋ āϏāĻ¤ā§āϝ āĻŽāĻžāύāĨ¤ āĻāχ āĻĒā§āϰāĻĨāĻŽ āϏāĻ¤ā§āϝ āĻŽāĻžāύ, āϝāĻž āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻž āĻšā§Ÿ. `three` āϏāĻŽāĻžāύ `[]`āĨ¤

@@ -3320,15 +3320,15 @@ secondFunction(); #### āωāĻ¤ā§āϤāϰ: D -With a promise, we basically say _I want to execute this function, but I'll put it aside for now while it's running since this might take a while. Only when a certain value is resolved (or rejected), and when the call stack is empty, I want to use this value._ +āĻāĻ•āϟāĻŋ āĻĒā§āϰāĻŽāĻŋāϏ⧇āϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡, āφāĻŽāϰāĻž āĻŽā§‚āϞāϤ āĻŦāϞāĻŋ, _āφāĻŽāĻŋ āĻāχ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āϚāĻžāϞāĻžāϤ⧇ āϚāĻžāχ, āĻ•āĻŋāĻ¨ā§āϤ⧁ āĻāϟāĻŋ āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖ āĻšāϤ⧇ āϏāĻŽāϝāĻŧ āϞāĻžāĻ—āϤ⧇ āĻĒāĻžāϰ⧇ āĻŦāϞ⧇ āĻāĻ–āύ āĻāϟāĻŋāϕ⧇ āĻāĻ•āĻĒāĻžāĻļ⧇ āϰ⧇āϖ⧇ āĻĻ⧇āĻŦāĨ¤ āϝāĻ–āύ āϕ⧋āύ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻ­ā§āϝāĻžāϞ⧁ āϰāĻŋāϏāĻ˛ā§āĻ­ (āĻŦāĻž āϰāĻŋāĻœā§‡āĻ•ā§āϟ) āĻšāϝāĻŧ, āĻāĻŦāĻ‚ āϝāĻ–āύ āĻ•āϞ āĻ¸ā§āĻŸā§āϝāĻžāĻ• āĻ–āĻžāϞāĻŋ āĻĨāĻžāϕ⧇, āĻ āĻŋāĻ• āϤāĻ–āύāχ āφāĻŽāĻŋ āĻāχ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāϤ⧇ āϚāĻžāχāĨ¤_ -We can get this value with both `.then` and the `await` keywords in an `async` function. Although we can get a promise's value with both `.then` and `await`, they work a bit differently. +āĻāĻ•āϟāĻŋ `async` āĻĢāĻžāĻ‚āĻļāύ āĻĨ⧇āϕ⧇ āĻāχ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āφāĻŽāϰāĻž `.then` āĻāĻŦāĻ‚ `await` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄ āĻĻ⧁āϟāĻŋ āĻĻāĻŋā§Ÿā§‡āχ āĻĒ⧇āϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ āϝāĻĻāĻŋāĻ“ āφāĻŽāϰāĻž `.then` āĻāĻŦāĻ‚ `await` āĻĻ⧁āĻ­āĻžāĻŦ⧇āχ āĻĒā§āϰāĻŽāĻŋāϏ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁ āĻĒ⧇āϤ⧇ āĻĒāĻžāϰāĻŋ, āϤāĻŦ⧇ āĻāϰāĻž āĻāĻ•āϟ⧁ āĻ­āĻŋāĻ¨ā§āύāĻ­āĻžāĻŦ⧇ āĻ•āĻžāϜ āĻ•āϰ⧇āĨ¤ -In the `firstFunction`, we (sort of) put the myPromise function aside while it was running, but continued running the other code, which is `console.log('second')` in this case. Then, the function resolved with the string `I have resolved`, which then got logged after it saw that the callstack was empty. +- `firstFunction` āĻ, āφāĻŽāϰāĻž (āϝ⧇āύ) myPromise āĻĢāĻžāĻ‚āĻļāύāϟāĻŋāϕ⧇ āĻāĻ•āĻĒāĻžāĻļ⧇ āϰ⧇āϖ⧇ āĻĻāĻŋā§Ÿā§‡āĻ›āĻŋāϞāĻžāĻŽ āϝāĻ–āύ āĻāϟāĻŋ āϚāϞāĻŽāĻžāύ āĻ›āĻŋāϞ, āĻ•āĻŋāĻ¨ā§āϤ⧁ āĻ…āĻ¨ā§āϝ āϕ⧋āĻĄāϗ⧁āϞ⧋ āϚāϞāϤ⧇ āĻĨāĻžāϕ⧇, āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ `console.log('second')`āĨ¤ āϤāĻžāϰāĻĒāϰ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ "I have resolved" āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āύāĻŋā§Ÿā§‡ āϰāĻŋāϏāĻ˛ā§āĻ­ āĻšā§Ÿ, āĻāĻŦāĻ‚ āĻāϟāĻŋāχ āĻĒāϰāĻŦāĻ°ā§āϤāĻŋāϤ⧇ āϞāĻ— āĻšā§Ÿā§‡āϛ⧇ āϝāĻ–āύ āϏ⧇ āĻ•āϞ āĻ¸ā§āĻŸā§āϝāĻžāĻ• āĻ–āĻžāϞāĻŋ āĻĒā§‡ā§Ÿā§‡āϛ⧇āĨ¤ -With the await keyword in `secondFunction`, we literally pause the execution of an async function until the value has been resolved before moving to the next line. +- `secondFunction` āĻ, `await` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄā§‡āϰ āϏāĻžāĻšāĻžāĻ¯ā§āϝ⧇ āφāĻŽāϰāĻž āφāĻ•ā§āώāϰāĻŋāĻ• āĻ…āĻ°ā§āĻĨ⧇ āĻāĻ•āϟāĻŋ `async` āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āĻ•āĻžāĻ°ā§āϝāĻ•ā§āϰāĻŽāϕ⧇ āĻŦāĻŋāϰāϤāĻŋ āĻĻāĻŋā§Ÿā§‡ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āύāĻŋāĻļā§āϚāĻŋāϤ (āϰāĻŋāϏāĻ˛ā§āĻ­) āύāĻž āĻšāĻ“ā§ŸāĻž āĻĒāĻ°ā§āϝāĻ¨ā§āϤ āĻ…āĻĒ⧇āĻ•ā§āώāĻž āĻ•āϰāĻŋ, āϤāĻžāϰāĻĒāϰ āĻĒāϰ⧇āϰ āϞāĻžāχāύ⧇ āϝāĻžāχāĨ¤ -This means that it waited for the `myPromise` to resolve with the value `I have resolved`, and only once that happened, we moved to the next line: `second` got logged. + āĻāϰ āĻŽāĻžāύ⧇ āĻšāϞ, āĻāϟāĻŋ `myPromise` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋāϰ `I have resolved` āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āύāĻŋā§Ÿā§‡ āϰāĻŋāϏāĻ˛ā§āĻ­ āĻšāĻ“ā§ŸāĻž āĻĒāĻ°ā§āϝāĻ¨ā§āϤ āĻ…āĻĒ⧇āĻ•ā§āώāĻž āĻ•āϰ⧇, āĻāĻŦāĻ‚ āϕ⧇āĻŦāϞ āϤāĻž āϘāϟāĻžāϰ āĻĒāϰ⧇āχ āφāĻŽāϰāĻž āĻĒāϰ⧇āϰ āϞāĻžāχāύ⧇ āĻ—āĻŋā§Ÿā§‡āĻ›āĻŋ: `second` āϞāĻ— āĻšā§Ÿā§‡āϛ⧇āĨ¤

@@ -3359,20 +3359,20 @@ for (let item of set) { #### āωāĻ¤ā§āϤāϰ: C -The `+` operator is not only used for adding numerical values, but we can also use it to concatenate strings. Whenever the JavaScript engine sees that one or more values are not a number, it coerces the number into a string. +`+` āĻ…āĻĒāĻžāϰ⧇āϟāϰāϟāĻŋ āĻļ⧁āϧ⧁āĻŽāĻžāĻ¤ā§āϰ āϏāĻ‚āĻ–ā§āϝāĻžāϏ⧂āϚāĻ• āĻ­ā§āϝāĻžāϞ⧁āχ āϝ⧋āĻ— āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāĻž āĻšāϝāĻŧ āύāĻž, āφāĻŽāϰāĻž āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āϏāĻ‚āϝ⧁āĻ•ā§āϤ (concatenate) āĻ•āϰāϤ⧇āĻ“ āĻāϟāĻŋ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ āϝāĻ–āύāχ āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āχāĻžā§āϜāĻŋāύ āĻĻ⧇āϖ⧇ āϝ⧇ āĻāĻ• āĻŦāĻž āĻāĻ•āĻžāϧāĻŋāĻ• āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞ⧋ āĻāĻ•āϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻž āύāϝāĻŧ, āĻāϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻžāϟāĻŋāϕ⧇ āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ā§Ÿā§‡ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇, āĻāϟāĻžāϕ⧇ āĻŦāϞāĻž āĻšā§Ÿ āĻ•ā§‹ā§ŸāĻžāĻ°ā§āĻļāύ ([coercion]([https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#type_coercion]))āĨ¤ -The first one is `1`, which is a numerical value. `1 + 2` returns the number 3. +āĻĒā§āϰāĻĨāĻŽāϟāĻŋ āĻšāϞ `1`, āϝāĻž āĻāĻ•āϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻžāϏ⧂āϚāĻ• āĻ­ā§āϝāĻžāϞ⧁āĨ¤ `1 + 2` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ āύāĻžāĻŽā§āĻŦāĻžāϰ `3`āĨ¤ -However, the second one is a string `"Lydia"`. `"Lydia"` is a string and `2` is a number: `2` gets coerced into a string. `"Lydia"` and `"2"` get concatenated, which results in the string `"Lydia2"`. +āĻ…āĻ¨ā§āϝāĻĻāĻŋāϕ⧇, āĻĻā§āĻŦāĻŋāϤ⧀āϝāĻŧāϟāĻŋ āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ `"Lydia"`āĨ¤ `"Lydia"` āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻāĻŦāĻ‚ `2` āĻšāϞ āĻāĻ•āϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻž: āϤāĻžāχ `2` āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āϝāĻŧ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāĻŋāϤ āĻšā§ŸāĨ¤ `"Lydia"` āĻāĻŦāĻ‚ `"2"` āĻāĻ•āĻ¤ā§āϰāĻŋāϤ āĻšāϝāĻŧ, āϝāĻžāϰ āĻĢāϞ⧇ `"Lydia2"` āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤ -`{ name: "Lydia" }` is an object. Neither a number nor an object is a string, so it stringifies both. Whenever we stringify a regular object, it becomes `"[object Object]"`. `"[object Object]"` concatenated with `"2"` becomes `"[object Object]2"`. +`{ name: "Lydia" }` āĻšāϞ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāĨ¤ āĻāĻ•āϟāĻŋ āύāĻžāĻŽā§āĻŦāĻžāϰ āĻŦāĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āϕ⧋āύāϟāĻžāχ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āύ⧟, āϤāĻžāχ āĻ āĻĻ⧁āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āĻĢāĻžāχ āĻšā§ŸāĨ¤ āϝāĻ–āύāĻŋ āφāĻŽāϰāĻž āĻāĻ•āϟāĻŋ āϏāĻžāϧāĻžāϰāĻŖ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āĻĢāĻžāχ āĻ•āϰāĻŋ āĻāϟāĻž āĻšā§Ÿā§‡ āϝāĻžā§Ÿ - `"[object Object]"`āĨ¤ `"[object Object]"` `"2"` āĻāϰ āϏāĻžāĻĨ⧇ āĻāĻ•āĻ¤ā§āϰāĻŋāϤ āĻšā§Ÿā§‡ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `"[object Object]2"`āĨ¤

--- -###### 104. What's its value? +###### 104. āĻāϟāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻ•āĻŋ āĻšāĻŦ⧇? ```javascript Promise.resolve(5); @@ -3388,16 +3388,16 @@ Promise.resolve(5); #### āωāĻ¤ā§āϤāϰ: C -We can pass any type of value we want to `Promise.resolve`, either a promise or a non-promise. The method itself returns a promise with the resolved value (``). If you pass a regular function, it'll be a resolved promise with a regular value. If you pass a promise, it'll be a resolved promise with the resolved value of that passed promise. +`Promise.resolve` āĻ āφāĻŽāϰāĻž āϝ⧇āϕ⧋āύ āϟāĻžāχāĻĒ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāϏ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ, āĻāĻ•āϟāĻŋ āĻĒā§āϰāĻŽāĻŋāϏ āĻŦāĻž āύāύ-āĻĒā§āϰāĻŽāĻŋāϏāĨ¤ āĻŽā§‡āĻĨāĻĄāϟāĻŋ āύāĻŋāĻœā§‡āχ āϰāĻŋāϏāĻ˛ā§āĻ­ āĻšāĻ“ā§ŸāĻž āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ (``) āϏāĻš āĻāĻ•āϟāĻŋ āĻĒā§āϰāĻŽāĻŋāϏ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤ āϝāĻĻāĻŋ āφāĻĒāύāĻŋ āĻāĻ•āϟāĻŋ āĻāĻ•āϟāĻŋ āϰ⧇āϗ⧁āϞāĻžāϰ āĻĢāĻžāĻ‚āĻļāύ āĻĒāĻžāϏ āĻ•āϰ⧇āύ, āĻāϟāĻž āĻāĻ•āϟāĻŋ āϰ⧇āϗ⧁āϞāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁ āϏāĻš āĻāĻ•āϟāĻŋ āϰāĻŋāϏāĻ˛ā§āĻ­ āĻĒā§āϰāĻŽāĻŋāϏ āĻšāĻŦ⧇āĨ¤ āϝāĻĻāĻŋ āĻĒā§āϰāĻŽāĻŋāϏ āĻĒāĻžāϏ āĻ•āϰ⧇āύ, āĻāϟāĻž āĻĒāĻžāϏ āĻ•āϰāĻž āϐ āĻĒā§āϰāĻŽāĻŋāϏ⧇āϰ āϰāĻŋāϏāĻ˛ā§āĻ­ āĻ­ā§āϝāĻžāϞ⧁ āϏāĻš āĻāĻ•āϟāĻŋ āϰāĻŋāϏāĻ˛ā§āĻ­ āĻĒā§āϰāĻŽāĻŋāϏ āĻšāĻŦ⧇āĨ¤ -In this case, we just passed the numerical value `5`. It returns a resolved promise with the value `5`. +āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āφāĻŽāϰāĻž āϕ⧇āĻŦāϞ āĻĒāĻžāϏ āĻ•āϰ⧇āĻ›āĻŋ āĻāĻ•āϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻžāϏ⧂āϚāĻ• āĻ­ā§āϝāĻžāϞ⧁ `5`āĨ¤ āϤāĻžāχ āĻāϟāĻž `5` āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋāϏāĻš āĻāĻ•āϟāĻŋ āϰāĻŋāϏāĻ˛ā§āĻ­ āĻĒā§āϰāĻŽāĻŋāϏ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āϛ⧇āĨ¤

--- -###### 105. What's its value? +###### 105. āĻāϟāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻ•āĻŋ āĻšāĻŦ⧇? ```javascript function compareMembers(person1, person2 = person) { @@ -3423,20 +3423,18 @@ compareMembers(person); #### āωāĻ¤ā§āϤāϰ: B -Objects are passed by reference. When we check objects for strict equality (`===`), we're comparing their references. +āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻĒāĻžāϏ āĻšā§Ÿ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āĻĻā§āĻŦāĻžāϰāĻžāĨ¤ āϝāĻ–āύ āφāĻŽāϰāĻž āĻ•āĻ ā§‹āϰ āϏāĻŽāϤāĻžāϰ (strict equality `===`) āϜāĻ¨ā§āϝ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϗ⧁āϞāĻŋ āĻĒāϰ⧀āĻ•ā§āώāĻž āĻ•āϰāĻŋ, āϤāĻ–āύ āφāĻŽāϰāĻž āφāĻĻāϤ⧇ āϤāĻžāĻĻ⧇āϰ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏāϗ⧁āϞāĻŋ āϤ⧁āϞāύāĻž āĻ•āϰāĻ›āĻŋāĨ¤ -We set the default value for `person2` equal to the `person` object, and passed the `person` object as the value for `person1`. +āφāĻŽāϰāĻž `person2`-āĻāϰ āĻāĻ•āϟāĻŋ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻ­ā§āϝāĻžāϞ⧁ āϏāĻŽāĻžāύ āϏ⧇āϟ āĻ•āϰ⧇āĻ›āĻŋ `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āĻāĻŦāĻ‚ `person1`-āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻšāĻŋāϏ⧇āĻŦ⧇āĻ“ āĻāĻ•āχ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ `person`āϕ⧇ āĻĒāĻžāϏ āĻ•āϰ⧇āĻ›āĻŋāĨ¤ āĻāϰ āĻŽāĻžāύ⧇ āĻšāϞ āϝ⧇ āωāϭ⧟ āĻ­ā§āϝāĻžāϞ⧁āϰ āĻ•āĻžāϛ⧇āχ āĻŽā§‡āĻŽāϰāĻŋāϰ āĻāĻ•āχ āϞ⧋āϕ⧇āĻļāύ⧇āϰ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āϰ⧟āϛ⧇, āĻāχāĻ­āĻžāĻŦ⧇ āϤāĻžāϰāĻž āϏāĻŽāĻžāύ āĻšā§ŸāĨ¤ -This means that both values have a reference to the same spot in memory, thus they are equal. - -The code block in the `else` statement gets run, and `They are the same!` gets logged. +āĻĢāϞ⧇, `else` āĻ¸ā§āĻŸā§‡āϟāĻŽā§āϝāĻžāĻ¨ā§āĻŸā§‡āϰ āϕ⧋āĻĄ āĻŦā§āϞāĻ•āϟāĻŋ āĻ•āĻžāĻ°ā§āϝāĻ•āϰ āĻšāϝāĻŧ, āĻāĻŦāĻ‚ `They are the same!` āϞāĻ— āĻšāϝāĻŧāĨ¤

--- -###### 106. What's its value? +###### 106. āĻāϟāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻ•āĻŋ āĻšāĻŦ⧇? ```javascript const colorConfig = { @@ -3462,18 +3460,18 @@ console.log(colorConfig.colors[1]); #### āωāĻ¤ā§āϤāϰ: D -In JavaScript, we have two ways to access properties on an object: bracket notation, or dot notation. In this example, we use dot notation (`colorConfig.colors`) instead of bracket notation (`colorConfig["colors"]`). +āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āĻŸā§‡, āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁ āφāĻŽāϰāĻž āĻĻ⧁āχāĻ­āĻžāĻŦ⧇ āĻāĻ•ā§āϏ⧇āϏ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋāσ āĻŦā§āĻ°ā§āϝāĻžāϕ⧇āϟ āύ⧋āĻŸā§‡āĻļāύ, āĻ…āĻĨāĻŦāĻž āĻĄāϟ āύ⧋āĻŸā§‡āĻļāύāĨ¤ āĻāχ āωāĻĻāĻžāĻšāϰāύ⧇, āφāĻŽāϰāĻž āĻĄāϟ āύ⧋āĻŸā§‡āĻļāύ (`colorConfig.colors`) āĻŦā§āϝāĻžāĻŦāĻšāĻžāϰ āĻ•āϰ⧇āĻ›āĻŋ āĻŦā§āĻ°ā§āϝāĻžāϕ⧇āϟ āύ⧋āĻŸā§‡āĻļāύ⧇āϰ (`colorConfig["colors"]`) āĻĒāϰāĻŋāĻŦāĻ°ā§āϤ⧇āĨ¤ -With dot notation, JavaScript tries to find the property on the object with that exact name. In this example, JavaScript tries to find a property called `colors` on the `colorConfig` object. There is no property called `colors`, so this returns `undefined`. Then, we try to access the value of the first element by using `[1]`. We cannot do this on a value that's `undefined`, so it throws a `TypeError`: `Cannot read property '1' of undefined`. +āĻĄāϟ āύ⧋āĻŸā§‡āĻļāύ⧇āϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡, āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āύāĻžāĻŽ āϧāϰ⧇ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁ āϖ⧁āρāĻœā§‡ āĻĒāĻžāĻ“ā§ŸāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰ⧇āĨ¤ āĻāχ āωāĻĻāĻžāĻšāϰāύ⧇, āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ `colorConfig` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ `colors` āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁ āϖ⧁āρāĻœā§‡ āĻĒāĻžāĻ“ā§ŸāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰ⧇āϛ⧇āĨ¤ āĻāĻ–āĻžāύ⧇ `colors` āύāĻžāĻŽā§‡ āϕ⧋āύ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āϖ⧁āρāĻœā§‡ āύāĻž āĻĒāĻžāĻ“ā§ŸāĻžā§Ÿ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇ `undefined`āĨ¤ āĻāϰāĻĒāϰ āφāĻŽāϰāĻž `[1]` āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ ā§§āĻŽ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟāϕ⧇ āĻāĻ•ā§āϏ⧇āϏ āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāĻ›āĻŋāĨ¤ āĻ•āĻŋāĻ¨ā§āϤ⧁ āφāĻŽāϰāĻž āĻāϟāĻž āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ āύāĻž āϝāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁ `undefined`, āϤāĻžāχ āĻāϟāĻŋ āϟāĻžāχāĻĒ āĻāϰāϰ āϘāϟāĻžāĻŦ⧇ - `TypeError`: `Cannot read property '1' of undefined`āĨ¤ -JavaScript interprets (or unboxes) statements. When we use bracket notation, it sees the first opening bracket `[` and keeps going until it finds the closing bracket `]`. Only then, it will evaluate the statement. If we would've used `colorConfig[colors[1]]`, it would have returned the value of the `red` property on the `colorConfig` object. +āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āĻ¸ā§āĻŸā§‡āϟāĻŽā§āϝāĻžāĻ¨ā§āϟāϗ⧁āϞ⧋āϕ⧇ āĻ­āĻžāώāĻžāĻ¨ā§āϤāϰ āĻ•āϰ⧇ (āĻŽā§‡āĻļāĻŋāύ⧇āϰ āĻ­āĻžāώāĻžā§Ÿ)āĨ¤ āϝāĻ–āύ āĻŦā§āĻ°ā§āϝāĻžāϕ⧇āϟ āύ⧋āĻŸā§‡āĻļāύ āĻŦā§āϝāĻŦāĻšā§ƒāϤ āĻšā§Ÿ, āĻāϟāĻž āĻļ⧁āϰ⧁āϰ āĻŦā§āĻ°ā§āϝāĻžāϕ⧇āϟ `[` āĻĒ⧇āϞ⧇ āϤāĻžāϰ āĻļ⧇āώ āĻŦā§āĻ°ā§āϝāĻžāϕ⧇āϟ āĻĒāĻ°ā§āϝāĻ¨ā§āϤ `]` āϝ⧇āϤ⧇ āĻĨāĻžāϕ⧇āĨ¤ āϤāĻžāϰāĻĒāϰāχ āϕ⧇āĻŦāϞ āĻāϟāĻžāϰ āĻŽāĻžāύ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĻž āĻšāĻŦ⧇āĨ¤ āφāĻŽāϰāĻž āϝāĻĻāĻŋ `colorConfig[colors[1]]` āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāϤāĻžāĻŽ, āĻāϟāĻž `colorConfig` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ `red` āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϤāĨ¤

--- -###### 107. What's its value? +###### 107. āĻāϟāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻ•āĻŋ āĻšāĻŦ⧇? ```javascript console.log('â¤ī¸' === 'â¤ī¸'); @@ -3487,14 +3485,14 @@ console.log('â¤ī¸' === 'â¤ī¸'); #### āωāĻ¤ā§āϤāϰ: A -Under the hood, emojis are unicodes. The unicodes for the heart emoji is `"U+2764 U+FE0F"`. These are always the same for the same emojis, so we're comparing two equal strings to each other, which returns true. +āϭ⧇āϤāϰ⧇ āϭ⧇āϤāϰ⧇, āχāĻŽā§‹āϜāĻŋāϗ⧁āϞāĻŋ āĻšāϞ āχāωāύāĻŋāϕ⧋āĻĄā§ˇ āĻšāĻžāĻ°ā§āϟ āχāĻŽā§‹āϜāĻŋāϰ āχāωāύāĻŋāϕ⧋āĻĄ āĻšāϞ `"U+2764 U+FE0F"`āĨ¤ āĻāχ āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞ⧋ āĻāĻ•āχ āχāĻŽā§‹āϜāĻŋāϗ⧁āϞāĻŋāϰ āϜāĻ¨ā§āϝ āϏāĻŦāϏāĻŽāϝāĻŧ āĻāĻ•āχ, āϤāĻžāχ āφāĻŽāϰāĻž āĻĻ⧁āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āϕ⧇ āĻāϕ⧇ āĻ…āĻĒāϰ⧇āϰ āϏāĻŽāĻžāύ āĻ•āĻŋāύāĻž āϤ⧁āϞāύāĻž āĻ•āϰāĻ›āĻŋ, āϝāĻž āϏāĻ¤ā§āϝ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤

--- -###### 108. Which of these methods modifies the original array? +###### 108. āĻāχ āĻŽā§‡āĻĨāĻĄāϗ⧁āϞāĻŋāϰ āĻŽāĻ§ā§āϝ⧇ āϕ⧋āύāϟāĻŋ āĻŽā§‚āϞ āĻ…ā§āϝāĻžāϰ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇? ```javascript const emojis = ['✨', 'đŸĨ‘', '😍']; @@ -3517,9 +3515,9 @@ emojis.splice(1, 2, '✨'); #### āωāĻ¤ā§āϤāϰ: D -With `splice` method, we modify the original array by deleting, replacing or adding elements. In this case, we removed 2 items from index 1 (we removed `'đŸĨ‘'` and `'😍'`) and added the ✨ emoji instead. +`splice` āĻŽā§‡āĻĨāĻĄā§‡āϰ āϏāĻžāĻšāĻžāĻ¯ā§āϝ⧇, āφāĻŽāϰāĻž āĻŽā§‚āϞ āĻ…ā§āϝāĻžāϰ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāĻŋ āϤāĻžāϰ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟāϗ⧁āϞāĻŋ āĻŦāĻžāĻĻ, āĻĒā§āϰāϤāĻŋāĻ¸ā§āĻĨāĻžāĻĒāύ āĻŦāĻž āϝ⧋āĻ— āĻ•āϰāĻžāϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡āĨ¤ āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āφāĻŽāϰāĻž āχāύāĻĄā§‡āĻ•ā§āϏ 1 āĻĨ⧇āϕ⧇ 2āϟāĻŋ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟāϕ⧇ āϏāϰāĻŋāϝāĻŧ⧇ (āφāĻŽāϰāĻž `'đŸĨ‘'` āĻāĻŦāĻ‚ `'😍'` āϏāϰāĻŋāϝāĻŧ⧇ āĻĻāĻŋāϝāĻŧ⧇āĻ›āĻŋ) āύāϤ⧁āύ ✨ āχāĻŽā§‹āϜāĻŋ āϝ⧋āĻ— āĻ•āϰ⧇āĻ›āĻŋāĨ¤ -`map`, `filter` and `slice` return a new array, `find` returns an element, and `reduce` returns a reduced value. +`map`, `filter` āĻāĻŦāĻ‚ `slice` āĻāĻ•āϟāĻŋ āύāϤ⧁āύ āĻ…ā§āϝāĻžāϰ⧇ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇, `find` āĻāĻ•āϟāĻŋ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ āĻāĻŦāĻ‚ `reduce` āĻāĻ•āϟāĻŋ āĻšā§āϰāĻžāϏāĻ•ā§ƒāϤ/āĻāĻ•āĻ¤ā§āϰāĻŋāϤ āĻ­ā§āϝāĻžāϞ⧁ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤

@@ -3547,18 +3545,18 @@ console.log(food); #### āωāĻ¤ā§āϤāϰ: A -We set the value of the `favoriteFood` property on the `info` object equal to the string with the pizza emoji, `'🍕'`. A string is a primitive data type. In JavaScript, primitive data types don't interact by reference. +āφāĻŽāϰāĻž `info` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ `favoriteFood` āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁ āϏāĻŽāĻžāύ āϏ⧇āϟ āĻ•āϰ⧇āĻ›āĻŋ āĻĒāĻŋā§ŽāϜāĻž āχāĻŽā§‹āϜāĻŋāϰ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ `'🍕'`āϕ⧇āĨ¤ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻšāĻšā§āϛ⧇ āĻāĻ•āϟāĻŋ āĻĒā§āϰāĻŋāĻŽāĻŋāϟāĻŋāĻ­ āĻĄā§‡āϟāĻž āϟāĻžāχāĻĒāĨ¤ āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āĻŸā§‡, āĻĒā§āϰāĻŋāĻŽāĻŋāϟāĻŋāĻ­ āĻĄā§‡āϟāĻž āϟāĻžāχāĻĒāϗ⧁āϞ⧋ āχāĻ¨ā§āϟāĻžāϰāĻ…ā§āϝāĻžāĻ•ā§āϟ āĻ•āϰ⧇ āĻ­ā§āϝāĻžāϞ⧁ āĻĻā§āĻŦāĻžāϰāĻž āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āĻĻā§āĻŦāĻžāϰāĻž āύ⧟āĨ¤ -In JavaScript, primitive data types (everything that's not an object) interact by _value_. In this case, we set the value of the `favoriteFood` property on the `info` object equal to the value of the first element in the `food` array, the string with the pizza emoji in this case (`'🍕'`). A string is a primitive data type, and interact by value (see my [blogpost](https://www.theavocoder.com/complete-javascript/2018/12/21/by-value-vs-by-reference) if you're interested in learning more) +āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āĻŸā§‡, āĻĒā§āϰāĻŋāĻŽāĻŋāϟāĻŋāĻ­ āĻĄā§‡āϟāĻž āϟāĻžāχāĻĒ (āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻ›āĻžā§œāĻž āϏāĻŦāĻ•āĻŋāϛ⧁āχ) āϤāĻžāĻĻ⧇āϰ _value_ āĻĻā§āĻŦāĻžāϰāĻž āχāĻ¨ā§āϟāĻžāϰāĻ…ā§āϝāĻžāĻ•ā§āϟ āĻ•āϰ⧇āĨ¤ āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āφāĻŽāϰāĻž `info` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ `favoriteFood` āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁ āϏāĻŽāĻžāύ āϏ⧇āϟ āĻ•āϰ⧇āĻ›āĻŋ `food` āĻ…ā§āϝāĻžāϰ⧇āϰ āĻĒā§āϰāĻĨāĻŽ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āĻ­ā§āϝāĻžāϞ⧁, āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ āĻĒāĻŋā§ŽāϜāĻž āχāĻŽā§‹āϜāĻŋāϰ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ (`'🍕'` )āĨ¤ -Then, we change the value of the `favoriteFood` property on the `info` object. The `food` array hasn't changed, since the value of `favoriteFood` was merely a _copy_ of the value of the first element in the array, and doesn't have a reference to the same spot in memory as the element on `food[0]`. When we log food, it's still the original array, `['🍕', 'đŸĢ', 'đŸĨ‘', '🍔']`. +āϤāĻžāϰāĻĒāϰ, āφāĻŽāϰāĻž `info` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ `favoriteFood` āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāĻŋāĨ¤ `food` āĻ…ā§āϝāĻžāϰ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāĻŋāϤ āĻšāϝāĻŧāύāĻŋ, āϝ⧇āĻšā§‡āϤ⧁ `favoriteFood`-āĻāϰ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āϕ⧇āĻŦāϞ āĻ…ā§āϝāĻžāϰ⧇āϰ āĻĒā§āϰāĻĨāĻŽ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āĻ­ā§āϝāĻžāϞ⧁āϰ āĻāĻ•āϟāĻŋ _copy_ āĻ›āĻŋāϞ, āĻāĻŦāĻ‚ āĻāĻ•āχ āĻŽā§‡āĻŽāϰāĻŋ āϞ⧋āϕ⧇āĻļāύ⧇āϰ `food[0]` āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āĻŽāϤ āϕ⧋āύ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āύ⧟āĨ¤ āϝāĻ–āύ food āϞāĻ— āĻ•āϰāĻž āĻšā§Ÿ, āĻāϟāĻž āĻāĻ–āύ⧋ āĻ…āϰāĻŋāϜāĻŋāύāĻžāϞ āĻ…ā§āϝāĻžāϰ⧇āχ āφāϛ⧇, `['🍕', 'đŸĢ', 'đŸĨ‘', '🍔']`āĨ¤

--- -###### 110. What does this method do? +###### 110. āĻāχ āĻŽā§‡āĻĨāĻĄāϟāĻŋ āĻ•āĻŋ āĻ•āϰ⧇? ```javascript JSON.parse(); @@ -3574,7 +3572,7 @@ JSON.parse(); #### āωāĻ¤ā§āϤāϰ: A -With the `JSON.parse()` method, we can parse JSON string to a JavaScript value. +`JSON.parse()` āĻŽā§‡āĻĨāĻĄ āĻŦā§āϝāĻžāĻŦāĻšāĻžāϰ āĻ•āϰ⧇, āφāĻŽāĻžāϰāĻž JSON āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āϕ⧇ āĻāĻ•āϟāĻŋ āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āĻ­ā§āϝāĻžāϞ⧁āϤ⧇ āĻĒāĻžāĻ°ā§āϏ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ ```javascript // Stringifying a number into valid JSON, then parsing the JSON string to a JavaScript value: @@ -3585,9 +3583,9 @@ JSON.parse(jsonNumber); // 4 const jsonArray = JSON.stringify([1, 2, 3]); // '[1, 2, 3]' JSON.parse(jsonArray); // [1, 2, 3] -// Stringifying an object into valid JSON, then parsing the JSON string to a JavaScript value: -const jsonArray = JSON.stringify({ name: 'Lydia' }); // '{"name":"Lydia"}' -JSON.parse(jsonArray); // { name: 'Lydia' } +// Stringifying an object into valid JSON, then parsing the JSON string to a JavaScript value: +const jsonObject = JSON.stringify({ name: 'Lydia' }); // '{"name":"Lydia"}' +JSON.parse(jsonObject); // { name: 'Lydia' } ```

@@ -3618,11 +3616,11 @@ getName(); #### āωāĻ¤ā§āϤāϰ: D -Each function has its own _execution context_ (or _scope_). The `getName` function first looks within its own context (scope) to see if it contains the variable `name` we're trying to access. In this case, the `getName` function contains its own `name` variable: we declare the variable `name` with the `let` keyword, and with the value of `'Sarah'`. +āĻĒā§āϰāϤāĻŋāϟāĻŋ āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āύāĻŋāϜāĻ¸ā§āĻŦ _execution context_ (āĻŦāĻž _scope_) āφāϛ⧇āĨ¤ `getName` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋāϤ⧇ āϝ⧇ āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞāϕ⧇ āĻāĻ•ā§āϏ⧇āϏ āĻ•āϰāĻž āĻšāĻšā§āϛ⧇ āϝ⧇āĻŽāύ, `name` āϤāĻžāϕ⧇ āĻĒā§āϰāĻĨāĻŽā§‡ āϤāĻžāϰ āύāĻŋāϜāĻ¸ā§āĻŦ _context_ (āĻŦāĻž _scope_)-āĻ āϖ⧁āρāĻœā§‡ āĻĻ⧇āĻ–āϛ⧇āĨ¤ āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, `getName` āĻĢāĻžāĻ‚āĻļāύ⧇ āϤāĻžāϰ āύāĻŋāϜāĻ¸ā§āĻŦ `name` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞ āφāϛ⧇āσ āφāĻŽāϰāĻž `name` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞāϕ⧇ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰ⧇āĻ›āĻŋ `let` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄ āĻĻāĻŋā§Ÿā§‡ āĻāĻŦāĻ‚ āχāύāĻŋāĻļāĻŋ⧟āĻžāϞāĻžāχāϜ āĻ•āϰ⧇āĻ›āĻŋ āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ - `'Sarah'`āĨ¤ -Variables with the `let` keyword (and `const`) are hoisted, but unlike `var`, don't get initialized. They are not accessible before the line we declare (initialize) them. This is called the "temporal dead zone". When we try to access the variables before they are declared, JavaScript throws a `ReferenceError`. +`let` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄ (āĻāĻŦāĻ‚ `const`) āĻĻāĻŋā§Ÿā§‡ āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞ āύāĻŋāϞ⧇ āϏ⧇āϟāĻžāĻ“ **āĻšāχāĻ¸ā§āĻŸā§‡āĻĄ āĻšā§Ÿ** āϤāĻŦ⧇ `var` āĻāϰ āĻŽāϤ **āχāύāĻŋāĻļāĻŋ⧟āĻžāϞāĻžāχāϜ āĻšā§Ÿ āύāĻž**āĨ¤ āϝ⧇ āϞāĻžāχāύ⧇ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ (āχāύāĻŋāĻļāĻŋ⧟āĻžāϞāĻžāχāϜ) āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇ āϤāĻžāϰ āφāϗ⧇ āϤāĻžāĻĻ⧇āϰāϕ⧇ āĻāĻ•ā§āϏ⧇āϏ (āϰāĻŋāĻĄ/āϰāĻžāχāϟ) āĻ•āϰāĻž āϝāĻžā§Ÿ āύāĻžāĨ¤ āĻāϟāĻžāϕ⧇ **"āĻŸā§‡āĻŽā§āĻĒā§‹āϰāĻžāϞ āĻĄā§‡āĻĄ āĻœā§‹āύ"** āĻŦāϞāĻž āĻšā§ŸāĨ¤ āϝāĻ–āύ āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞāϕ⧇ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰāĻžāϰ āφāϗ⧇āχ āϤāĻžāϕ⧇ āĻāĻ•ā§āϏ⧇āϏ āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāĻž āĻšā§Ÿ āϤāĻ–āύ āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ `ReferenceError` āϛ⧁āρāĻā§œā§‡ āĻĻā§‡ā§ŸāĨ¤ -If we wouldn't have declared the `name` variable within the `getName` function, the javascript engine would've looked down the _scope chain_. The outer scope has a variable called `name` with the value of `Lydia`. In that case, it would've logged `Lydia`. +āϝāĻĻāĻŋ `name` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞāϟāĻŋāϕ⧇ āφāĻŽāϰāĻž `getName` āĻĢāĻžāĻ‚āĻļāύ⧇ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āύāĻž āĻ•āϰāϤāĻžāĻŽ, āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āχāĻžā§āϜāĻŋāύ āϤāĻžāϕ⧇ _scope chain_ āĻāϰ āĻ­āĻŋāϤāϰ āϖ⧁āρāĻœā§‡ āĻĻ⧇āĻ–āϤāĨ¤ āĻŦāĻžāχāϰ⧇āϰ āĻ¸ā§āϕ⧋āĻĒ⧇āĻ“ āĻāĻ•āϟāĻŋ `name` āĻ­ā§āϝāĻžāϰāĻŋ⧟āĻžāĻŦāϞ āφāϛ⧇ āϝāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ - `Lydia`āĨ¤ āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āĻāϟāĻž āϞāĻ— āĻ•āϰāϤ `Lydia`āĨ¤ ```javascript let name = 'Lydia'; From b1d37523a1bd7156c256f5f3a7de5440004a193a Mon Sep 17 00:00:00 2001 From: iamsaief Date: Thu, 13 Jun 2024 13:46:35 +0600 Subject: [PATCH 09/12] added translation till 122 --- bn-BD/README_bn-BD.md | 62 ++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/bn-BD/README_bn-BD.md b/bn-BD/README_bn-BD.md index fb94bcef..5284585b 100644 --- a/bn-BD/README_bn-BD.md +++ b/bn-BD/README_bn-BD.md @@ -3665,16 +3665,17 @@ console.log(two.next().value); #### āωāĻ¤ā§āϤāϰ: C -With the `yield` keyword, we `yield` values in a generator function. With the `yield*` keyword, we can yield values from another generator function, or iterable object (for example an array). +`yield` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄ āĻĻāĻŋā§Ÿā§‡, āφāĻŽāϰāĻž āĻœā§‡āύāĻžāϰ⧇āϟāϰ āĻĢāĻžāĻ‚āĻļāύ āĻĨ⧇āϕ⧇ āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞ⧋ `yield` āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ `yield*` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄ āĻĻāĻŋā§Ÿā§‡, āφāĻŽāϰāĻž āĻ…āĻ¨ā§āϝ āĻœā§‡āύāĻžāϰ⧇āϟāϰ āĻĢāĻžāĻ‚āĻļāύ āĻĨ⧇āϕ⧇ āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞ⧋, āĻŦāĻž āχāϟāĻžāϰ⧇āĻŦāϞ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ (āϝ⧇āĻŽāύ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇) āĻĨ⧇āϕ⧇ āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞ⧋ `yield` āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ -In `generatorOne`, we yield the entire array `['a', 'b', 'c']` using the `yield` keyword. The value of `value` property on the object returned by the `next` method on `one` (`one.next().value`) is equal to the entire array `['a', 'b', 'c']`. +`generatorOne` āĻ, āφāĻŽāϰāĻž `yield` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ āϏāĻŽā§āĻĒ⧁āĻ°ā§āύ āĻ…ā§āϝāĻžāϰ⧇ `['a', 'b', 'c']` -āϕ⧇ `yield` āĻ•āϰāĻ›āĻŋāĨ¤ +`one` āĻāϰ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, (`one.next().value`) āĻāϰ `next` āĻŽā§‡āĻĨāĻĄā§‡āϰ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ `value` āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁ āϏāĻŽāĻžāύ āĻšāϞ⧋ āϏāĻŽā§āĻĒ⧁āĻ°ā§āύ āĻ…ā§āϝāĻžāϰ⧇āϟāĻŋ- `['a', 'b', 'c']`āĨ¤ ```javascript console.log(one.next().value); // ['a', 'b', 'c'] console.log(one.next().value); // undefined ``` -In `generatorTwo`, we use the `yield*` keyword. This means that the first yielded value of `two`, is equal to the first yielded value in the iterator. The iterator is the array `['a', 'b', 'c']`. The first yielded value is `a`, so the first time we call `two.next().value`, `a` is returned. +`generatorTwo` āĻ, āφāĻŽāϰāĻž `yield*` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇āĻ›āĻŋāĨ¤ āĻāϰ āĻŽāĻžāύ⧇ āĻšāϞ⧋, `two` āĻ āĻĒā§āϰāĻĨāĻŽ yield āĻšāĻ“ā§ŸāĻž āĻ­ā§āϝāĻžāϞ⧁ āϏāĻŽāĻžāύ āĻšāĻšā§āϛ⧇ āχāϟāĻžāϰ⧇āϟāϰ⧇āϰ (`['a', 'b', 'c']`) āĻĒā§āϰāĻĨāĻŽ yield āĻšāĻ“ā§ŸāĻž āĻ­ā§āϝāĻžāϞ⧁āĨ¤ āĻĒā§āϰāĻĨāĻŽ yield āĻšāĻ“ā§ŸāĻž āĻ­ā§āϝāĻžāϞ⧁ āĻšāϞ⧋ `a`, āϤāĻžāχ āĻĒā§āϰāĻĨāĻŽāĻŦāĻžāϰ `two.next().value` āĻ•āϞ āĻ•āϰāϞ⧇ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `a`āĨ¤ ```javascript console.log(two.next().value); // 'a' @@ -3704,14 +3705,14 @@ console.log(`${((x) => x)('I love')} to program`); #### āωāĻ¤ā§āϤāϰ: A -Expressions within template literals are evaluated first. This means that the string will contain the returned value of the expression, the immediately invoked function `(x => x)('I love')` in this case. We pass the value `'I love'` as an argument to the `x => x` arrow function. `x` is equal to `'I love'`, which gets returned. This results in `I love to program`. +āĻŸā§‡āĻŽāĻĒā§āϞ⧇āϟ āϞāĻŋāϟāĻžāϰ⧇āϞ⧇āϰ āĻŽāĻ§ā§āϝ⧇ āĻĨāĻžāĻ•āĻž āĻāĻ•ā§āϏāĻĒā§āϰ⧇āĻļāύ⧇āϰ āĻŽāĻžāύ āύāĻŋāĻ°ā§āϪ⧟ āĻšā§Ÿ āϏāĻ°ā§āĻŦāĻĒā§āϰāĻĨāĻŽā§‡āĨ¤ āĻāϰ āĻŽāĻžāύ⧇ āĻšāϞ⧋, āĻāĻ•ā§āϏāĻĒā§āϰ⧇āĻļāύ āĻĨ⧇āϕ⧇ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻž āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻāϰ āĻŽāĻ§ā§āϝ⧇ āĻĨāĻžāĻ•āĻŦ⧇, āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, `(x => x)('I love')` āχāĻŽāĻŋāĻĄāĻŋā§Ÿā§‡āϟāϞāĻŋ āχāύāĻ­ā§‹āĻ•āĻĄ āĻĢāĻžāĻ‚āĻļāύāĨ¤ āφāĻŽāϰāĻž `x => x` āĻ…ā§āϝāĻžāϰ⧋ āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āĻāĻ•āϟāĻŋ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āĻšāĻŋāϏ⧇āĻŦ⧇ `'I love'` āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚āϟāĻŋ āĻĒāĻžāϏ āĻ•āϰāĻ›āĻŋāĨ¤ āϤāĻžāχ `x` āϏāĻŽāĻžāύ āĻšā§Ÿ `'I love'`, āϝ⧇āϟāĻž āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻž āĻšā§ŸāĨ¤ āϤāĻžāχ āĻĢāϞāĻžāĻĢāϞ āĻšāĻŋāϏ⧇āĻŦ⧇ `I love to program` āĻĒāĻžāĻ“ā§ŸāĻž āϝāĻžāĻšā§āϛ⧇āĨ¤

--- -###### 114. What will happen? +###### 114. āĻāĻ–āĻžāύ⧇ āĻ•āĻŋ āϘāϟāĻŦ⧇? ```javascript let config = { @@ -3733,18 +3734,16 @@ config = null; #### āωāĻ¤ā§āϤāϰ: C -Normally when we set objects equal to `null`, those objects get _garbage collected_ as there is no reference anymore to that object. However, since the callback function within `setInterval` is an arrow function (thus bound to the `config` object), the callback function still holds a reference to the `config` object. -As long as there is a reference, the object won't get garbage collected. -Since this is an interval, setting `config` to `null` or `delete`-ing `config.alert` won't garbage-collect the interval, so the interval will still be called. -It should be cleared with `clearInterval(config.alert)` to remove it from memory. -Since it was not cleared, the `setInterval` callback function will still get invoked every 1000ms (1s). +āϏāϧāĻžāϰāύāϤ āϝāĻ–āύ āφāĻŽāϰāĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āϏāĻŽāĻžāύ `null` āϏ⧇āϟ āĻ•āϰāĻŋ, āϏ⧇āχ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϗ⧁āϞ⧋ _āĻ—āĻžāϰāĻŦ⧇āϜ āĻ•āĻžāϞ⧇āĻ•ā§āĻŸā§‡āĻĄ_ āĻšā§Ÿā§‡ āϝāĻžā§Ÿ āϝ⧇āĻšā§‡āϤ⧁ āϐ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āφāϰ āϕ⧋āύ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āĻĨāĻžāϕ⧇ āύāĻžāĨ¤ āĻ…āĻ¨ā§āϝāĻĻāĻŋāϕ⧇, āϝ⧇āĻšā§‡āϤ⧁ `setInterval` āĻāϰ āĻ•āϞāĻŦā§āϝāĻžāĻ• āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧋ āĻĢāĻžāĻ‚āĻļāύ (āĻāϜāĻ¨ā§āϝ `config` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϭ⧇āϤāϰ āφāĻŦāĻĻā§āϧ āĻĨāĻžāĻ•āϛ⧇), āĻ•āϞāĻŦā§āϝāĻžāĻ• āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻāĻ–āύ⧋ `config` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āϧāϰ⧇ āϰ⧇āϖ⧇āϛ⧇āĨ¤ + +āϝāϤāĻ•ā§āώāĻŖ āĻĒāĻ°ā§āϝāĻ¨ā§āϤ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āĻĨāĻžāĻ•āϛ⧇, āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϟāĻŋ _āĻ—āĻžāϰāĻŦ⧇āϜ āĻ•āĻžāϞ⧇āĻ•ā§āĻŸā§‡āĻĄ_ āĻšāĻŦ⧇ āύāĻžāĨ¤ āϝ⧇āĻšā§‡āϤ⧁ āĻāϟāĻŋ āχāĻ¨ā§āϟāĻžāϰāĻ­āĻžāϞ (āϟāĻžāχāĻŽāĻžāϰ), `config` āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ `null` āϏ⧇āϟ āĻ•āϰāĻž āĻŦāĻž `delete` āĻ•āϰāϞ⧇āĻ“ āχāĻ¨ā§āϟāĻžāϰāĻ­āĻžāϞ _āĻ—āĻžāϰāĻŦ⧇āϜ āĻ•āĻžāϞ⧇āĻ•ā§āĻŸā§‡āĻĄ_ āĻšāĻŦ⧇ āύāĻž, āϤāĻžāχ āχāĻ¨ā§āϟāĻžāϰāĻ­āĻžāϞāϟāĻŋ āĻāĻ–āύ⧋ āĻ•āϞ āĻšāĻŦ⧇āĨ¤ āĻāϟāĻžāϕ⧇ āĻŽā§‡āĻŽāϰāĻŋ āĻĨ⧇āϕ⧇ āĻŽā§āϛ⧇ āĻĢ⧇āϞāĻžāϰ āϜāĻ¨ā§āϝ āĻāϕ⧇ āĻ•ā§āϞāĻŋ⧟āĻžāϰ āĻ•āϰāĻž āωāϚāĻŋā§Ž `clearInterval(config.alert)` āĻĻāĻŋā§Ÿā§‡āĨ¤ āϝ⧇āĻšā§‡āϤ⧁ āĻāϟāĻŋ āĻ•ā§āϞāĻŋ⧟āĻžāϰ āĻšā§ŸāύāĻŋ, `setInterval` āĻāϰ āĻ•āϞāĻŦā§āϝāĻžāĻ• āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻāĻ–āύ⧋ āĻ•āϞ āĻšāϤ⧇ āĻĨāĻžāĻ•āĻŦ⧇ āĻĒā§āϰāϤāĻŋ ā§§ā§Ļā§Ļā§Ļ āĻŽāĻŋāϞāĻŋāϏ⧇āϕ⧇āĻ¨ā§āĻĄ (ā§§ āϏ⧇āϕ⧇āĻ¨ā§āĻĄ) āĻĒāϰāĻĒāϰāĨ¤

--- -###### 115. Which method(s) will return the value `'Hello world!'`? +###### 115. āϕ⧋āύ āĻŽā§‡āĻĨāĻĄ(āϗ⧁āϞ⧋) `'Hello world!'` āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻŦ⧇? ```javascript const myMap = new Map(); @@ -3770,12 +3769,12 @@ myMap.get(() => 'greeting'); #### āωāĻ¤ā§āϤāϰ: B -When adding a key/value pair using the `set` method, the key will be the value of the first argument passed to the `set` function, and the value will be the second argument passed to the `set` function. The key is the _function_ `() => 'greeting'` in this case, and the value `'Hello world'`. `myMap` is now `{ () => 'greeting' => 'Hello world!' }`. +āϝāĻ–āύ `set` āĻŽā§‡āĻĨāĻĄ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ āĻ•āĻŋ/āĻ­ā§āϝāĻžāϞ⧁ āĻœā§‹ā§œ āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻž āĻšā§Ÿ, `set` āĻŽā§‡āĻĨāĻĄā§‡ āĻĒāĻžāϏ āĻ•āϰāĻž āĻĒā§āϰāĻĨāĻŽ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āĻšāĻŦ⧇ _āĻ•āĻŋ_ āĻāĻŦāĻ‚ āĻĻā§āĻŦāĻŋāĻ¤ā§€ā§ŸāϟāĻŋ āĻšāĻŦ⧇ _āĻ­ā§āϝāĻžāϞ⧁_āĨ¤ āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ _āĻ•āĻŋ_ āĻšāϞ⧋ _function_ `() => 'greeting'` āĻāĻŦāĻ‚ _āĻ­ā§āϝāĻžāϞ⧁_ āĻšāϞ⧋ `'Hello world'`āĨ¤ āĻĢāϞ⧇ `myMap` āĻāĻ–āύ āĻšā§Ÿ āĻāĻŽāύ - `{ () => 'greeting' => 'Hello world!' }` -1 is wrong, since the key is not `'greeting'` but `() => 'greeting'`. -3 is wrong, since we're creating a new function by passing it as a parameter to the `get` method. Object interacts by _reference_. Functions are objects, which is why two functions are never strictly equal, even if they are identical: they have a reference to a different spot in memory. +**1**, `myMap.get('greeting')`āϟāĻŋ āϭ⧁āϞ, āϝ⧇āĻšāϤ⧁ āĻ•āĻŋ `'greeting'` āύ⧟ āĻŦāϰāĻ‚ `() => 'greeting'`āĨ¤ + +**3**, `myMap.get(() => 'greeting')` āϟāĻŋāĻ“ āϭ⧁āϞ, āϝ⧇āĻšā§‡āϤ⧁ āφāĻŽāϰāĻž āύāϤ⧁āύ āĻāĻ•āϟāĻŋ āĻĢāĻžāĻ‚āĻļāύ āϤ⧈āϰāĻŋ āĻ•āϰāĻ›āĻŋ āĻāϟāĻžāϕ⧇ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ āĻšāĻŋāϏ⧇āĻŦ⧇ `set` āĻŽā§‡āĻĨāĻĄā§‡ āĻĒāĻžāϏ āĻ•āϰāĻžāϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡āĨ¤ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ _reference_ āĻĻā§āĻŦāĻžāϰāĻž āχāĻ¨ā§āϟāĻžāϰāĻ…ā§āϝāĻžāĻ•ā§āϟ āĻ•āϰ⧇āĨ¤ āĻĢāĻžāĻ‚āĻļāύ āĻšāϞ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ, āϝ⧇ āĻ•āĻžāϰāϪ⧇ āĻĻ⧁āϟāĻŋ āĻĢāĻžāĻ‚āĻļāύ āĻ•āĻ–āύ⧋āχ āĻ•āĻ ā§‹āϰāĻ­āĻžāĻŦ⧇ āϏāĻŽāĻžāύ āĻšāϝāĻŧ āύāĻž, āĻāĻŽāύāĻ•āĻŋ āϤāĻžāϰāĻž āϝāĻĻāĻŋ āĻšā§āĻŦāĻšā§ āĻāĻ•āχ āĻšā§Ÿ: āϤāĻžāĻĻ⧇āϰ āĻ•āĻžāϛ⧇ āĻŽā§‡āĻŽāϰāĻŋāϤ⧇ āφāϞāĻžāĻĻāĻž āφāϞāĻžāĻĻāĻž āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āĻĨāĻžāϕ⧇āĨ¤ -

--- @@ -3810,18 +3809,18 @@ console.log(person); #### āωāĻ¤ā§āϤāϰ: C -Both the `changeAge` and `changeAgeAndName` functions have a default parameter, namely a _newly_ created object `{ ...person }`. This object has copies of all the key/values in the `person` object. +`changeAge` āĻāĻŦāĻ‚ `changeAgeAndName` āωāĻ­āϝāĻŧ āĻĢāĻžāĻ‚āĻļāύ⧇āϰāχ āĻāĻ•āϟāĻŋ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ āφāϛ⧇, āωāĻ˛ā§āϞ⧇āĻ–ā§āϝ āĻāϰāĻž _āύāϤ⧁āύ_ āϤ⧈āϰāĻŋāĻ•ā§ƒāϤ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ `{ ...person }`āĨ¤ āĻāχ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϏāĻŽāĻ¸ā§āϤ āϕ⧀/āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞāĻŋāϰ āĻ•āĻĒāĻŋ āϰāϝāĻŧ⧇āϛ⧇⧎ -First, we invoke the `changeAge` function and pass the `person` object as its argument. This function increases the value of the `age` property by 1. `person` is now `{ name: "Lydia", age: 22 }`. +āĻĒā§āϰāĻĨāĻŽāϤ, āφāĻŽāϰāĻž `changeAge` āĻĢāĻžāĻ‚āĻļāύāϕ⧇ āĻ•āϞ āĻ•āϰāĻŋ āĻāĻŦāĻ‚ `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϟāĻŋāϕ⧇ āĻāϰ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āĻšāĻŋāϏ⧇āĻŦ⧇ āĻĒāĻžāϏ āĻ•āϰāĻŋāĨ¤ āĻāχ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ `age` āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϰ āĻŽāĻžāύ 1 āĻĻā§āĻŦāĻžāϰāĻž āĻŦ⧃āĻĻā§āϧāĻŋ āĻ•āϰ⧇āĨ¤ `person` āĻāĻ–āύ `{ name: "Lydia", age: 22 }`āĨ¤ -Then, we invoke the `changeAgeAndName` function, however we don't pass a parameter. Instead, the value of `x` is equal to a _new_ object: `{ ...person }`. Since it's a new object, it doesn't affect the values of the properties on the `person` object. `person` is still equal to `{ name: "Lydia", age: 22 }`. +āϤāĻžāϰāĻĒāϰ, āφāĻŽāϰāĻž `changeAgeAndName` āĻĢāĻžāĻ‚āĻļāύ āĻ•āϞ āĻ•āϰāĻŋ, āϤāĻŦ⧇ āφāĻŽāϰāĻž āϕ⧋āύ⧋ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ āĻĒāĻžāϏ āĻ•āϰāĻŋāύāĻŋāĨ¤ āĻĢāϞ⧇, `x` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āϏāĻŽāĻžāύ āĻšā§Ÿ _āύāϤ⧁āύ_ āϤ⧈āϰāĻŋāĻ•ā§ƒāϤ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ `{ ...person }`āĨ¤ āϝ⧇āĻšā§‡āϤ⧁ āĻāϟāĻŋ āĻāĻ•āϟāĻŋ āύāϤ⧁āύ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ, āĻāϟāĻŋ `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϕ⧋āύ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇ āĻĒā§āϰāĻ­āĻžāĻŦāĻŋāϤ āĻ•āϰ⧇ āύāĻžāĨ¤ `person` āĻāĻ–āύāĻ“ `{ name: "Lydia", age: 22 }` āĻāϰ āϏāĻŽāĻžāύāĨ¤

--- -###### 117. Which of the following options will return `6`? +###### 117. āωāĻ˛ā§āϞ⧇āĻ–ā§āϝ āϕ⧋āύ āĻ…āĻĒāĻļāύāϟāĻŋ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `6`? ```javascript function sumValues(x, y, z) { @@ -3839,7 +3838,7 @@ function sumValues(x, y, z) { #### āωāĻ¤ā§āϤāϰ: C -With the spread operator `...`, we can _spread_ iterables to individual elements. The `sumValues` function receives three arguments: `x`, `y` and `z`. `...[1, 2, 3]` will result in `1, 2, 3`, which we pass to the `sumValues` function. +āĻ¸ā§āĻĒā§āϰ⧇āĻĄ āĻ…āĻĒāĻžāϰ⧇āϟāϰ āĻĻāĻŋā§Ÿā§‡ `...`, āφāĻŽāϰāĻž āχāϟāĻžāϰ⧇āĻŦāϞ āϗ⧁āϞ⧋āϕ⧇ āφāϞāĻĻāĻž āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āĻŸā§‡ āĻ¸ā§āĻĒā§āϰ⧇āĻĄ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ `sumValues` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ ā§ŠāϟāĻŋ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āϰāĻŋāϏāĻŋāĻ­ āĻ•āϰāϛ⧇ `x`, `y` āĻ“ `z`āĨ¤ āϕ⧇āĻŦāϞ `...[1, 2, 3]` -āĻāϰ āĻĢāϞāĻžāĻĢāϞ āĻšā§Ÿ `1, 2, 3`, āϝ⧇āϟāĻž āφāĻŽāϰāĻž `sumValues` āĻĢāĻžāĻ‚āĻļāύ⧇ āĻĒāĻžāϏ āĻ•āϰ⧇āĻ›āĻŋāĨ¤

@@ -3865,7 +3864,7 @@ console.log(list[(num += 1)]); #### āωāĻ¤ā§āϤāϰ: B -With the `+=` operator, we're incrementing the value of `num` by `1`. `num` had the initial value `1`, so `1 + 1` is `2`. The item on the second index in the `list` array is đŸĨ°, `console.log(list[2])` prints đŸĨ°. +`+=` āĻ…āĻĒāĻžāϰ⧇āϟāϰ āĻĻāĻŋā§Ÿā§‡, āφāĻŽāϰāĻž `num` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ `1` āĻŦ⧃āĻĻā§āϧāĻŋ āĻ•āϰāĻ›āĻŋāĨ¤ `num` āĻāϰ āĻĒā§āϰāĻžāĻĨāĻŽāĻŋāĻ• āĻ­ā§āϝāĻžāϞ⧁ āĻ›āĻŋāϞ `1`, āĻĢāϞ⧇ `1 + 1` āĻšā§Ÿ `2`āĨ¤ `list` āĻ…ā§āϝāĻžāϰ⧇āϰ ⧍ āύāĻžāĻŽā§āĻŦāĻžāϰ āχāύāĻĄā§‡āĻ•ā§āϏ āφāχāĻŸā§‡āĻŽā§‡āϰ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāĻ“ā§ŸāĻž āϝāĻžā§Ÿ đŸĨ°, `console.log(list[2])` āĻĒā§āϰāĻŋāĻ¨ā§āϟ āĻ•āϰāϛ⧇ đŸĨ°āĨ¤

@@ -3903,12 +3902,15 @@ console.log(member.getLastName?.()); #### āωāĻ¤ā§āϤāϰ: B -With the optional chaining operator `?.`, we no longer have to explicitly check whether the deeper nested values are valid or not. If we're trying to access a property on an `undefined` or `null` value (_nullish_), the expression short-circuits and returns `undefined`. +āĻ…āĻĒāĻļāύāĻžāϞ āĻšā§‡āχāύāĻŋāĻ‚ āĻ…āĻĒāĻžāϰ⧇āϟāϰ `?.` āĻĻāĻŋā§Ÿā§‡, āϕ⧋āύ āĻĄāĻŋāĻĒāĻžāϰ āύ⧇āĻ¸ā§āĻŸā§‡āĻĄ āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞ⧋ āĻ­ā§āϝāĻžāϞāĻŋāĻĄ āĻ•āĻŋāύāĻž āϤāĻž āφāĻŽāĻžāĻĻ⧇āϰ āϏāϰāĻžāϏāϰāĻŋ āĻšā§‡āĻ• āĻ•āϰāĻžāϰ āĻĒā§āĻ°ā§Ÿā§‹āϜāύ āĻšā§Ÿ āύāĻž āϝ⧇āĨ¤ āϝāĻĻāĻŋ āφāĻŽāϰāĻž āϕ⧋āύ `undefined` āĻŦāĻž `null` āĻ­ā§āϝāĻžāϞ⧁ (_āύāĻžāϞāĻŋāĻļ_) āϕ⧇ āĻāĻ•ā§āϏ⧇āϏ āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāĻŋ, āĻāĻ•ā§āϏāĻĒā§āϰ⧇āĻļāύāϟāĻŋ āϏ⧇āĻ–āĻžāύ⧇āχ āĻ•āĻžāϜ āĻ•āϰāĻž āĻŦāĻ¨ā§āϧ āĻ•āϰ⧇ āĻĻā§‡ā§Ÿ āĻāĻŦāĻ‚ `undefined` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤ + +- `person.pet?.name` āĻāϰ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ `pet` āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āφāϛ⧇āσ `person.pet` āύāĻžāϞāĻŋāĻļ āύ⧟āĨ¤ āĻāϟāĻžā§Ÿ `name` āύāĻžāĻŽā§‡āϰ āĻāĻ•āϟāĻŋ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āφāϛ⧇, āĻāĻŦāĻ‚ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇ `Mara`āĨ¤ + +- `person.pet?.family?.name` āĻāϰ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ `pet` āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āφāϛ⧇āσ `person.pet` āύāĻžāϞāĻŋāĻļ āύ⧟āĨ¤ āĻāϟāĻžā§Ÿ `family` āύāĻžāĻŽā§‡āϰ āϕ⧋āύ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āύ⧇āχ, `person.pet.family` āĻšāϞ⧋ āύāĻžāϞāĻŋāĻļāĨ¤ āĻāĻ•ā§āϏāĻĒā§āϰ⧇āĻļāύāϟāĻŋ `undefined` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤ + +- `person.getFullName?.()` āĻāϰ āĻ•ā§āώāĻ¤ā§āϰ⧇, `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ `getFullName` āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āφāϛ⧇āσ `person.getFullName()` āύāĻžāϞāĻŋāĻļ āύ⧟ āĻāĻŦāĻ‚ āĻ•āϞ āĻ•āϰāϤ⧇ āĻĒ⧇āϰ⧇āϛ⧇, āϝ⧇āϟāĻž `Lydia Hallie` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇āĨ¤ -`person.pet?.name`: `person` has a property named `pet`: `person.pet` is not nullish. It has a property called `name`, and returns `Mara`. -`person.pet?.family?.name`: `person` has a property named `pet`: `person.pet` is not nullish. `pet` does _not_ have a property called `family`, `person.pet.family` is nullish. The expression returns `undefined`. -`person.getFullName?.()`: `person` has a property named `getFullName`: `person.getFullName()` is not nullish and can get invoked, which returns `Lydia Hallie`. -`member.getLastName?.()`: variable `member` is non-existent therefore a `ReferenceError` gets thrown! +- `member.getLastName?.()` āĻāϰ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, `member` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞāϟāĻŋāϕ⧇āχ āĻĒāĻžāĻ“ā§ŸāĻž āϝāĻžāĻšā§āϛ⧇ āύāĻž āĻŦāϞ⧇ `ReferenceError` āϘāϟāϛ⧇āĨ¤

@@ -3937,7 +3939,7 @@ if (groceries.indexOf('banana')) { #### āωāĻ¤ā§āϤāϰ: B -We passed the condition `groceries.indexOf("banana")` to the if-statement. `groceries.indexOf("banana")` returns `0`, which is a falsy value. Since the condition in the if-statement is falsy, the code in the `else` block runs, and `We don't have to buy bananas!` gets logged. +āφāĻŽāϰāĻž āχāĻĢ-āĻāϞāϏ āĻ¸ā§āĻŸā§‡āϟāĻŽā§‡āĻ¨ā§āĻŸā§‡ `groceries.indexOf("banana")` āĻļāĻ°ā§āϤ āĻĻāĻŋā§Ÿā§‡āĻ›āĻŋāĨ¤ `groceries.indexOf("banana")` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `0`, āϝ⧇āϟāĻž āĻĢāϞāϏāĻŋ āĻ­ā§āϝāĻžāϞ⧁āĨ¤ āϝ⧇āϤ⧇āϤ⧁ āχāĻĢ-āĻāϞāϏ āĻ¸ā§āĻŸā§‡āϟāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āĻļāĻ°ā§āϤ āĻĢāϞāϏāĻŋ, āϤāĻžāχ `else` āĻŦā§āϞāϕ⧇āϰ āϕ⧋āĻĄāϟāĻŋ āϚāϞ⧇āϛ⧇, āĻāĻŦāĻ‚ `We don't have to buy bananas!` āϞāĻ— āĻšā§Ÿā§‡āϛ⧇āĨ¤

@@ -3967,7 +3969,7 @@ console.log(config.language); #### āωāĻ¤ā§āϤāϰ: D -The `language` method is a `setter`. Setters don't hold an actual value, their purpose is to _modify_ properties. When calling a `setter` method, `undefined` gets returned. +`language` āĻŽā§‡āĻĨāĻĄāϟāĻŋ āĻšāϞ⧋ āĻāĻ•āϟāĻŋ `setter`āĨ¤ Setters āϕ⧋āύ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇āχ āϧāϰ⧇ āϰāĻžāϖ⧇ āύāĻž, āϤāĻžāĻĻ⧇āϰ āωāĻĻā§āĻĻā§āϝ⧇āĻļāχ āĻšāϞ⧋ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϗ⧁āϞ⧋āϕ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāĻžāĨ¤ āϝāĻ–āύ `setter` āĻŽā§‡āĻĨāĻĄ āĻ•āϞ āĻ•āϰāĻž āĻšā§Ÿ, `undefined` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤

@@ -3993,9 +3995,9 @@ console.log(!typeof name === 'string'); #### āωāĻ¤ā§āϤāϰ: C -`typeof name` returns `"string"`. The string `"string"` is a truthy value, so `!typeof name` returns the boolean value `false`. `false === "object"` and `false === "string"` both return`false`. +`typeof name` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `"string"`āĨ¤ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ - `"string"` āĻšāϞ⧋ āĻāĻ•āϟāĻŋ āϏāĻ¤ā§āϝ āĻ­ā§āϝāĻžāϞ⧁, āϤāĻžāχ `!typeof name` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ āĻŦ⧁āϞāĻŋ⧟āĻžāύ āĻ­ā§āϝāĻžāϞ⧁ `false`āĨ¤ `false === "object"` āĻāĻŦāĻ‚ `false === "string"` āωāĻ­ā§Ÿā§‡āχ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `false`āĨ¤ -(If we wanted to check whether the type was (un)equal to a certain type, we should've written `!==` instead of `!typeof`) +(āϝāĻĻāĻŋ āφāĻŽāϰāĻž āĻšā§‡āĻ• āĻ•āϰāϤ⧇ āϚāĻžāχāϤāĻžāĻŽ āϝ⧇ āϕ⧋āύ āĻāĻ•āϟāĻŋ āϟāĻžāχāĻĒ āĻāĻ•āϟāĻŋ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āϟāĻžāχāĻĒ⧇āϰ (āĻ…)āϏāĻŽāĻžāύ āĻ•āĻŋāύāĻž, āφāĻŽāĻžāĻĻ⧇āϰ `!typeof` āĻāϰ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤ⧇ `!==` āϞ⧇āĻ–āĻž āωāϚāĻŋā§Ž āĻ›āĻŋāϞ āĨ¤)

From 098e645ce5c2900ca3771562f7767eb4d7ab1b6c Mon Sep 17 00:00:00 2001 From: iamsaief Date: Sat, 20 Jul 2024 22:50:18 +0600 Subject: [PATCH 10/12] added translation till 133 --- bn-BD/README_bn-BD.md | 460 +++++++++++++++++++++--------------------- 1 file changed, 232 insertions(+), 228 deletions(-) diff --git a/bn-BD/README_bn-BD.md b/bn-BD/README_bn-BD.md index 5284585b..af201342 100644 --- a/bn-BD/README_bn-BD.md +++ b/bn-BD/README_bn-BD.md @@ -52,7 +52,7 @@ function sayHi() { console.log(name); console.log(age); - var name = 'Lydia'; + var name = "Lydia"; let age = 21; } @@ -148,7 +148,7 @@ console.log(shape.perimeter()); ```javascript +true; -!'Lydia'; +!"Lydia"; ``` - A: `1` and `false` @@ -173,11 +173,11 @@ console.log(shape.perimeter()); ```javascript const bird = { - size: 'small', + size: "small", }; const mouse = { - name: 'Mickey', + name: "Mickey", small: true, }; ``` @@ -206,11 +206,11 @@ const mouse = { ###### 6. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -let c = { greeting: 'Hey!' }; +let c = { greeting: "Hey!" }; let d; d = c; -c.greeting = 'Hello'; +c.greeting = "Hello"; console.log(d.greeting); ``` @@ -280,13 +280,13 @@ class Chameleon { return this.newColor; } - constructor({ newColor = 'green' } = {}) { + constructor({ newColor = "green" } = {}) { this.newColor = newColor; } } -const freddie = new Chameleon({ newColor: 'purple' }); -console.log(freddie.colorChange('orange')); +const freddie = new Chameleon({ newColor: "purple" }); +console.log(freddie.colorChange("orange")); ``` - A: `orange` @@ -341,10 +341,10 @@ console.log(greetign); ```javascript function bark() { - console.log('Woof!'); + console.log("Woof!"); } -bark.animal = 'dog'; +bark.animal = "dog"; ``` - A: Nothing, this is totally fine! @@ -374,7 +374,7 @@ function Person(firstName, lastName) { this.lastName = lastName; } -const member = new Person('Lydia', 'Hallie'); +const member = new Person("Lydia", "Hallie"); Person.getFullName = function () { return `${this.firstName} ${this.lastName}`; }; @@ -415,8 +415,8 @@ function Person(firstName, lastName) { this.lastName = lastName; } -const lydia = new Person('Lydia', 'Hallie'); -const sarah = Person('Sarah', 'Smith'); +const lydia = new Person("Lydia", "Hallie"); +const sarah = Person("Sarah", "Smith"); console.log(lydia); console.log(sarah); @@ -486,7 +486,7 @@ function sum(a, b) { return a + b; } -sum(1, '2'); +sum(1, "2"); ``` - A: `NaN` @@ -553,7 +553,7 @@ function getPersonInfo(one, two, three) { console.log(three); } -const person = 'Lydia'; +const person = "Lydia"; const age = 21; getPersonInfo`${person} is ${age} years old`; @@ -580,9 +580,9 @@ getPersonInfo`${person} is ${age} years old`; ```javascript function checkAge(data) { if (data === { age: 18 }) { - console.log('You are an adult!'); + console.log("You are an adult!"); } else if (data == { age: 18 }) { - console.log('You are still an adult.'); + console.log("You are still an adult."); } else { console.log(`Hmm.. You don't have an age I guess`); } @@ -642,7 +642,7 @@ getAge(21); ```javascript function getAge() { - 'use strict'; + "use strict"; age = 21; console.log(age); } @@ -670,7 +670,7 @@ getAge(); ###### 21. āϕ⧋āύāϟāĻŋ `sum` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻšāĻŦ⧇? ```javascript -const sum = eval('10*10+5'); +const sum = eval("10*10+5"); ``` - A: `105` @@ -693,7 +693,7 @@ const sum = eval('10*10+5'); ###### 22. āĻ•āϤāĻ•ā§āώāĻŖ cool_secret āĻāĻ•ā§āϏ⧇āϏāϝ⧋āĻ—ā§āϝ? ```javascript -sessionStorage.setItem('cool_secret', 123); +sessionStorage.setItem("cool_secret", 123); ``` - A: Forever, the data doesn't get lost. @@ -746,12 +746,12 @@ console.log(num); ###### 24. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const obj = { 1: 'a', 2: 'b', 3: 'c' }; +const obj = { 1: "a", 2: "b", 3: "c" }; const set = new Set([1, 2, 3, 4, 5]); -obj.hasOwnProperty('1'); +obj.hasOwnProperty("1"); obj.hasOwnProperty(1); -set.has('1'); +set.has("1"); set.has(1); ``` @@ -777,7 +777,7 @@ set.has(1); ###### 25. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const obj = { a: 'one', b: 'two', a: 'three' }; +const obj = { a: "one", b: "two", a: "three" }; console.log(obj); ``` @@ -846,10 +846,10 @@ for (let i = 1; i < 5; i++) { ```javascript String.prototype.giveLydiaPizza = () => { - return 'Just give Lydia pizza already!'; + return "Just give Lydia pizza already!"; }; -const name = 'Lydia'; +const name = "Lydia"; console.log(name.giveLydiaPizza()); ``` @@ -877,8 +877,8 @@ console.log(name.giveLydiaPizza()); ```javascript const a = {}; -const b = { key: 'b' }; -const c = { key: 'c' }; +const b = { key: "b" }; +const c = { key: "c" }; a[b] = 123; a[c] = 456; @@ -910,9 +910,9 @@ console.log(a[b]); ###### 30. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const foo = () => console.log('First'); -const bar = () => setTimeout(() => console.log('Second')); -const baz = () => console.log('Third'); +const foo = () => console.log("First"); +const bar = () => setTimeout(() => console.log("Second")); +const baz = () => console.log("Third"); bar(); foo(); @@ -1018,7 +1018,7 @@ If we click `p`, we see two logs: `p` and `div`. During event propagation, there ###### 33. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const person = { name: 'Lydia' }; +const person = { name: "Lydia" }; function sayHi(age) { return `${this.name} is ${age}`; @@ -1081,8 +1081,8 @@ console.log(typeof sayHi()); ```javascript 0; new Number(0); -(''); -(' '); +(""); +(" "); new Boolean(false); undefined; ``` @@ -1265,7 +1265,7 @@ console.log(numbers); ```javascript !!null; -!!''; +!!""; !!1; ``` @@ -1295,7 +1295,7 @@ console.log(numbers); ###### 42. āĻāχ `setInterval` āĻŽā§‡āĻĨāĻĄāϟāĻŋ āĻŦā§āϰāĻžāωāϜāĻžāϰ⧇ āĻ•āĻŋ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇? ```javascript -setInterval(() => console.log('Hi'), 1000); +setInterval(() => console.log("Hi"), 1000); ``` - A: a unique id @@ -1318,7 +1318,7 @@ setInterval(() => console.log('Hi'), 1000); ###### 43. āĻāϟāĻž āĻ•āĻŋ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇? ```javascript -[...'Lydia']; +[..."Lydia"]; ``` - A: `["L", "y", "d", "i", "a"]` @@ -1377,11 +1377,11 @@ console.log(gen.next().value); ```javascript const firstPromise = new Promise((res, rej) => { - setTimeout(res, 500, 'one'); + setTimeout(res, 500, "one"); }); const secondPromise = new Promise((res, rej) => { - setTimeout(res, 100, 'two'); + setTimeout(res, 100, "two"); }); Promise.race([firstPromise, secondPromise]).then((res) => console.log(res)); @@ -1407,7 +1407,7 @@ Promise.race([firstPromise, secondPromise]).then((res) => console.log(res)); ###### 46. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -let person = { name: 'Lydia' }; +let person = { name: "Lydia" }; const members = [person]; person = null; @@ -1447,7 +1447,7 @@ console.log(members); ```javascript const person = { - name: 'Lydia', + name: "Lydia", age: 21, }; @@ -1476,7 +1476,7 @@ for (const item in person) { ###### 48. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -console.log(3 + 4 + '5'); +console.log(3 + 4 + "5"); ``` - A: `"345"` @@ -1503,7 +1503,7 @@ console.log(3 + 4 + '5'); ###### 49. `num` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āϕ⧋āύāϟāĻŋ? ```javascript -const num = parseInt('7*6', 10); +const num = parseInt("7*6", 10); ``` - A: `42` @@ -1529,7 +1529,7 @@ const num = parseInt('7*6', 10); ```javascript [1, 2, 3].map((num) => { - if (typeof num === 'number') return; + if (typeof num === "number") return; return num * 2; }); ``` @@ -1557,12 +1557,12 @@ const num = parseInt('7*6', 10); ```javascript function getInfo(member, year) { - member.name = 'Lydia'; - year = '1998'; + member.name = "Lydia"; + year = "1998"; } -const person = { name: 'Sarah' }; -const birthYear = '1997'; +const person = { name: "Sarah" }; +const birthYear = "1997"; getInfo(person, birthYear); @@ -1594,15 +1594,15 @@ console.log(person, birthYear); ```javascript function greeting() { - throw 'Hello world!'; + throw "Hello world!"; } function sayHi() { try { const data = greeting(); - console.log('It worked!', data); + console.log("It worked!", data); } catch (e) { - console.log('Oh no an error:', e); + console.log("Oh no an error:", e); } } @@ -1632,8 +1632,8 @@ sayHi(); ```javascript function Car() { - this.make = 'Lamborghini'; - return { make: 'Maserati' }; + this.make = "Lamborghini"; + return { make: "Maserati" }; } const myCar = new Car(); @@ -1711,7 +1711,7 @@ Dog.prototype.bark = function () { console.log(`Woof I am ${this.name}`); }; -const pet = new Dog('Mara'); +const pet = new Dog("Mara"); pet.bark(); @@ -1776,7 +1776,7 @@ export default counter; ```javascript // index.js -import myCounter from './counter'; +import myCounter from "./counter"; myCounter += 1; @@ -1805,7 +1805,7 @@ console.log(myCounter); ###### 58. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const name = 'Lydia'; +const name = "Lydia"; age = 21; console.log(delete name); @@ -1876,7 +1876,7 @@ console.log(y); ###### 60. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const user = { name: 'Lydia', age: 21 }; +const user = { name: "Lydia", age: 21 }; const admin = { admin: true, ...user }; console.log(admin); @@ -1902,9 +1902,9 @@ console.log(admin); ###### 61. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const person = { name: 'Lydia' }; +const person = { name: "Lydia" }; -Object.defineProperty(person, 'age', { value: 21 }); +Object.defineProperty(person, "age", { value: 21 }); console.log(person); console.log(Object.keys(person)); @@ -1933,12 +1933,12 @@ console.log(Object.keys(person)); ```javascript const settings = { - username: 'lydiahallie', + username: "lydiahallie", level: 19, health: 90, }; -const data = JSON.stringify(settings, ['level', 'health']); +const data = JSON.stringify(settings, ["level", "health"]); console.log(data); ``` @@ -2126,12 +2126,12 @@ class Labrador extends Dog { ```javascript // index.js -console.log('running index.js'); -import { sum } from './sum.js'; +console.log("running index.js"); +import { sum } from "./sum.js"; console.log(sum(1, 2)); // sum.js -console.log('running sum.js'); +console.log("running sum.js"); export const sum = (a, b) => a + b; ``` @@ -2159,7 +2159,7 @@ export const sum = (a, b) => a + b; ```javascript console.log(Number(2) === Number(2)); console.log(Boolean(false) === Boolean(false)); -console.log(Symbol('foo') === Symbol('foo')); +console.log(Symbol("foo") === Symbol("foo")); ``` - A: `true`, `true`, `false` @@ -2182,7 +2182,7 @@ console.log(Symbol('foo') === Symbol('foo')); ###### 69. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const name = 'Lydia Hallie'; +const name = "Lydia Hallie"; console.log(name.padStart(13)); console.log(name.padStart(2)); ``` @@ -2209,7 +2209,7 @@ console.log(name.padStart(2)); ###### 70. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -console.log('đŸĨ‘' + 'đŸ’ģ'); +console.log("đŸĨ‘" + "đŸ’ģ"); ``` - A: `"đŸĨ‘đŸ’ģ"` @@ -2233,11 +2233,11 @@ console.log('đŸĨ‘' + 'đŸ’ģ'); ```javascript function* startGame() { - const answer = yield 'Do you love JavaScript?'; - if (answer !== 'Yes') { + const answer = yield "Do you love JavaScript?"; + if (answer !== "Yes") { return "Oh wow... Guess we're done here"; } - return 'JavaScript loves you back â¤ī¸'; + return "JavaScript loves you back â¤ī¸"; } const game = startGame(); @@ -2305,7 +2305,7 @@ console.log(String.raw`Hello\nworld`); ```javascript async function getData() { - return await Promise.resolve('I made it!'); + return await Promise.resolve("I made it!"); } const data = getData(); @@ -2342,7 +2342,7 @@ function addToList(item, list) { return list.push(item); } -const result = addToList('apple', ['banana']); +const result = addToList("apple", ["banana"]); console.log(result); ``` @@ -2402,7 +2402,7 @@ console.log(shape); ###### 76. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const { firstName: myName } = { firstName: 'Lydia' }; +const { firstName: myName } = { firstName: "Lydia" }; console.log(firstName); ``` @@ -2420,7 +2420,7 @@ console.log(firstName); [āĻĄāĻŋāĻ¸ā§āĻŸā§āϰāĻžāĻ•āϚāĻžāϰāĻŋāĻ‚ āĻ…ā§āϝāĻžāϏāĻžāχāύāĻŽā§‡āĻ¨ā§āϟ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) āϏāĻŋāύāĻŸā§āϝāĻžāĻ•ā§āϏ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇, āφāĻŽāϰāĻž āĻ…ā§āϝāĻžāϰ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁, āĻŦāĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āĻŦ⧇āϰ āĻ•āϰ⧇ āφāϞāĻžāĻĻāĻž āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞ⧇ āϰāĻžāĻ–āϤ⧇ āĻĒāĻžāϰāĻŋāσ ```javascript -const { firstName } = { firstName: 'Lydia' }; +const { firstName } = { firstName: "Lydia" }; // ES5 version: // var firstName = { firstName: 'Lydia' }.firstName; @@ -2430,7 +2430,7 @@ console.log(firstName); // "Lydia" āφāĻŦāĻžāϰ, āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻĨ⧇āϕ⧇ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āĻŦ⧇āϰ āĻ•āϰ⧇ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϐ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϰ āύāĻžāĻŽā§‡ āύāĻž āϰ⧇āϖ⧇ āĻ…āĻ¨ā§āϝ āύāĻžāĻŽā§‡āϰ āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞ⧇āĻ“ āϰāĻžāĻ–āϤ⧇ āĻĒāĻžāϰāĻŋāσ ```javascript -const { firstName: myName } = { firstName: 'Lydia' }; +const { firstName: myName } = { firstName: "Lydia" }; // ES5 version: // var myName = { firstName: 'Lydia' }.firstName; @@ -2443,7 +2443,7 @@ console.log(firstName); // Uncaught ReferenceError: firstName is not defined **āĻĻā§āϰāĻˇā§āϟāĻŦā§āϝ:** `āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ¸ā§āϕ⧋āĻĒ` āĻŦ⧈āĻļāĻŋāĻˇā§āĻŸā§āϝ āϏāĻŽā§āĻĒāĻ°ā§āϕ⧇ āϏāĻšā§‡āϤāύ āĻĨāĻžāϕ⧁āύ: ```javascript -const { name: myName } = { name: 'Lydia' }; +const { name: myName } = { name: "Lydia" }; console.log(myName); // "lydia" console.log(name); // "" ----- Browser e.g. Chrome @@ -2538,7 +2538,7 @@ console.log(addFunction(5 * 2)); ###### 79. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const myLifeSummedUp = ['☕', 'đŸ’ģ', '🍷', 'đŸĢ']; +const myLifeSummedUp = ["☕", "đŸ’ģ", "🍷", "đŸĢ"]; for (let item in myLifeSummedUp) { console.log(item); @@ -2634,13 +2634,13 @@ console.log(sayHi()); ###### 82. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -var status = '😎'; +var status = "😎"; setTimeout(() => { - const status = '😍'; + const status = "😍"; const data = { - status: 'đŸĨ‘', + status: "đŸĨ‘", getStatus() { return this.status; }, @@ -2674,12 +2674,12 @@ setTimeout(() => { ```javascript const person = { - name: 'Lydia', + name: "Lydia", age: 21, }; let city = person.city; -city = 'Amsterdam'; +city = "Amsterdam"; console.log(person); ``` @@ -2743,7 +2743,7 @@ console.log(checkAge(21)); ###### 85. āĻāĻ–āĻžāύ⧇ āĻ•āĻŋ āϧāϰāύ⧇āϰ āϤāĻĨā§āϝ āϞāĻ— āĻšāϤ⧇ āĻĒāĻžāϰ⧇? ```javascript -fetch('https://www.website.com/api/user/1') +fetch("https://www.website.com/api/user/1") .then((res) => res.json()) .then((res) => console.log(res)); ``` @@ -2799,7 +2799,7 @@ D-āϰ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, `name.length` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ ###### 87. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -console.log('I want pizza'[0]); +console.log("I want pizza"[0]); ``` - A: `"""` @@ -2854,11 +2854,11 @@ sum(10); ```javascript // module.js -export default () => 'Hello world'; -export const name = 'Lydia'; +export default () => "Hello world"; +export const name = "Lydia"; // index.js -import * as data from './module'; +import * as data from "./module"; console.log(data); ``` @@ -2891,7 +2891,7 @@ class Person { } } -const member = new Person('John'); +const member = new Person("John"); console.log(typeof member); ``` @@ -2951,11 +2951,10 @@ console.log(newList.push(5)); ```javascript function giveLydiaPizza() { - return 'Here is pizza!'; + return "Here is pizza!"; } -const giveLydiaChocolate = () => - "Here's chocolate... now go hit the gym already."; +const giveLydiaChocolate = () => "Here's chocolate... now go hit the gym already."; console.log(giveLydiaPizza.prototype); console.log(giveLydiaChocolate.prototype); @@ -2982,7 +2981,7 @@ console.log(giveLydiaChocolate.prototype); ```javascript const person = { - name: 'Lydia', + name: "Lydia", age: 21, }; @@ -3043,7 +3042,7 @@ function getItems(fruitList, favoriteFruit, ...args) { return [...fruitList, ...args, favoriteFruit]; } -getItems(['banana', 'apple'], 'pear', 'orange'); +getItems(["banana", "apple"], "pear", "orange"); ``` āωāĻĒāϰ⧇āϰ āωāĻĻāĻžāĻšāϰāĻŖāϟāĻŋ āϏāĻ āĻŋāĻ•āĻ­āĻžāĻŦ⧇ āĻ•āĻžāϜ āĻ•āϰ⧇āĨ¤ āĻāϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇ `[ 'banana', 'apple', 'orange', 'pear' ]` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ āĻĻ⧇āϝāĻŧāĨ¤ @@ -3057,8 +3056,8 @@ getItems(['banana', 'apple'], 'pear', 'orange'); ```javascript function nums(a, b) { - if (a > b) console.log('a is bigger'); - else console.log('b is bigger'); + if (a > b) console.log("a is bigger"); + else console.log("b is bigger"); return; a + b; } @@ -3098,13 +3097,13 @@ a + b; ```javascript class Person { constructor() { - this.name = 'Lydia'; + this.name = "Lydia"; } } Person = class AnotherPerson { constructor() { - this.name = 'Sarah'; + this.name = "Sarah"; } }; @@ -3133,7 +3132,7 @@ console.log(member.name); ```javascript const info = { - [Symbol('a')]: 'b', + [Symbol("a")]: "b", }; console.log(info); @@ -3202,7 +3201,7 @@ console.log(getUser(user)) ###### 99. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const name = 'Lydia'; +const name = "Lydia"; console.log(name()); ``` @@ -3235,8 +3234,8 @@ console.log(name()); ```javascript // 🎉✨ This is my 100th question! ✨🎉 -const output = `${[] && 'Im'}possible! -You should${'' && `n't`} see a therapist after so much JavaScript lol`; +const output = `${[] && "Im"}possible! +You should${"" && `n't`} see a therapist after so much JavaScript lol`; ``` - A: `possible! You should see a therapist after so much JavaScript lol` @@ -3262,7 +3261,7 @@ You should${'' && `n't`} see a therapist after so much JavaScript lol`; ```javascript const one = false || {} || null; -const two = null || false || ''; +const two = null || false || ""; const three = [] || 0 || true; console.log(one, two, three); @@ -3294,16 +3293,16 @@ console.log(one, two, three); ###### 102. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āĻŸā§‡āϰ āĻ­ā§āϝāĻžāϞ⧁ āĻ•āĻŋ? ```javascript -const myPromise = () => Promise.resolve('I have resolved!'); +const myPromise = () => Promise.resolve("I have resolved!"); function firstFunction() { myPromise().then((res) => console.log(res)); - console.log('second'); + console.log("second"); } async function secondFunction() { console.log(await myPromise()); - console.log('second'); + console.log("second"); } firstFunction(); @@ -3341,8 +3340,8 @@ secondFunction(); const set = new Set(); set.add(1); -set.add('Lydia'); -set.add({ name: 'Lydia' }); +set.add("Lydia"); +set.add({ name: "Lydia" }); for (let item of set) { console.log(item + 2); @@ -3402,13 +3401,13 @@ Promise.resolve(5); ```javascript function compareMembers(person1, person2 = person) { if (person1 !== person2) { - console.log('Not the same!'); + console.log("Not the same!"); } else { - console.log('They are the same!'); + console.log("They are the same!"); } } -const person = { name: 'Lydia' }; +const person = { name: "Lydia" }; compareMembers(person); ``` @@ -3445,7 +3444,7 @@ const colorConfig = { yellow: false, }; -const colors = ['pink', 'red', 'blue']; +const colors = ["pink", "red", "blue"]; console.log(colorConfig.colors[1]); ``` @@ -3474,7 +3473,7 @@ console.log(colorConfig.colors[1]); ###### 107. āĻāϟāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻ•āĻŋ āĻšāĻŦ⧇? ```javascript -console.log('â¤ī¸' === 'â¤ī¸'); +console.log("â¤ī¸" === "â¤ī¸"); ``` - A: `true` @@ -3495,14 +3494,14 @@ console.log('â¤ī¸' === 'â¤ī¸'); ###### 108. āĻāχ āĻŽā§‡āĻĨāĻĄāϗ⧁āϞāĻŋāϰ āĻŽāĻ§ā§āϝ⧇ āϕ⧋āύāϟāĻŋ āĻŽā§‚āϞ āĻ…ā§āϝāĻžāϰ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇? ```javascript -const emojis = ['✨', 'đŸĨ‘', '😍']; +const emojis = ["✨", "đŸĨ‘", "😍"]; -emojis.map((x) => x + '✨'); -emojis.filter((x) => x !== 'đŸĨ‘'); -emojis.find((x) => x !== 'đŸĨ‘'); -emojis.reduce((acc, cur) => acc + '✨'); -emojis.slice(1, 2, '✨'); -emojis.splice(1, 2, '✨'); +emojis.map((x) => x + "✨"); +emojis.filter((x) => x !== "đŸĨ‘"); +emojis.find((x) => x !== "đŸĨ‘"); +emojis.reduce((acc, cur) => acc + "✨"); +emojis.slice(1, 2, "✨"); +emojis.splice(1, 2, "✨"); ``` - A: `All of them` @@ -3527,10 +3526,10 @@ emojis.splice(1, 2, '✨'); ###### 109. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const food = ['🍕', 'đŸĢ', 'đŸĨ‘', '🍔']; +const food = ["🍕", "đŸĢ", "đŸĨ‘", "🍔"]; const info = { favoriteFood: food[0] }; -info.favoriteFood = '🍝'; +info.favoriteFood = "🍝"; console.log(food); ``` @@ -3584,7 +3583,7 @@ const jsonArray = JSON.stringify([1, 2, 3]); // '[1, 2, 3]' JSON.parse(jsonArray); // [1, 2, 3] // Stringifying an object into valid JSON, then parsing the JSON string to a JavaScript value: -const jsonObject = JSON.stringify({ name: 'Lydia' }); // '{"name":"Lydia"}' +const jsonObject = JSON.stringify({ name: "Lydia" }); // '{"name":"Lydia"}' JSON.parse(jsonObject); // { name: 'Lydia' } ``` @@ -3596,11 +3595,11 @@ JSON.parse(jsonObject); // { name: 'Lydia' } ###### 111. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -let name = 'Lydia'; +let name = "Lydia"; function getName() { console.log(name); - let name = 'Sarah'; + let name = "Sarah"; } getName(); @@ -3623,7 +3622,7 @@ getName(); āϝāĻĻāĻŋ `name` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞāϟāĻŋāϕ⧇ āφāĻŽāϰāĻž `getName` āĻĢāĻžāĻ‚āĻļāύ⧇ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āύāĻž āĻ•āϰāϤāĻžāĻŽ, āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āχāĻžā§āϜāĻŋāύ āϤāĻžāϕ⧇ _scope chain_ āĻāϰ āĻ­āĻŋāϤāϰ āϖ⧁āρāĻœā§‡ āĻĻ⧇āĻ–āϤāĨ¤ āĻŦāĻžāχāϰ⧇āϰ āĻ¸ā§āϕ⧋āĻĒ⧇āĻ“ āĻāĻ•āϟāĻŋ `name` āĻ­ā§āϝāĻžāϰāĻŋ⧟āĻžāĻŦāϞ āφāϛ⧇ āϝāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻāĻ•āϟāĻŋ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ - `Lydia`āĨ¤ āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āĻāϟāĻž āϞāĻ— āĻ•āϰāϤ `Lydia`āĨ¤ ```javascript -let name = 'Lydia'; +let name = "Lydia"; function getName() { console.log(name); @@ -3641,11 +3640,11 @@ getName(); // Lydia ```javascript function* generatorOne() { - yield ['a', 'b', 'c']; + yield ["a", "b", "c"]; } function* generatorTwo() { - yield* ['a', 'b', 'c']; + yield* ["a", "b", "c"]; } const one = generatorOne(); @@ -3692,7 +3691,7 @@ console.log(two.next().value); // undefined ###### 113. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -console.log(`${((x) => x)('I love')} to program`); +console.log(`${((x) => x)("I love")} to program`); ``` - A: `I love to program` @@ -3717,7 +3716,7 @@ console.log(`${((x) => x)('I love')} to program`); ```javascript let config = { alert: setInterval(() => { - console.log('Alert!'); + console.log("Alert!"); }, 1000), }; @@ -3747,16 +3746,16 @@ config = null; ```javascript const myMap = new Map(); -const myFunc = () => 'greeting'; +const myFunc = () => "greeting"; -myMap.set(myFunc, 'Hello world!'); +myMap.set(myFunc, "Hello world!"); //1 -myMap.get('greeting'); +myMap.get("greeting"); //2 myMap.get(myFunc); //3 -myMap.get(() => 'greeting'); +myMap.get(() => "greeting"); ``` - A: 1 @@ -3783,14 +3782,14 @@ myMap.get(() => 'greeting'); ```javascript const person = { - name: 'Lydia', + name: "Lydia", age: 21, }; const changeAge = (x = { ...person }) => (x.age += 1); const changeAgeAndName = (x = { ...person }) => { x.age += 1; - x.name = 'Sarah'; + x.name = "Sarah"; }; changeAge(person); @@ -3849,7 +3848,7 @@ function sumValues(x, y, z) { ```javascript let num = 1; -const list = ['đŸĨŗ', '🤠', 'đŸĨ°', 'đŸ¤Ē']; +const list = ["đŸĨŗ", "🤠", "đŸĨ°", "đŸ¤Ē"]; console.log(list[(num += 1)]); ``` @@ -3875,11 +3874,11 @@ console.log(list[(num += 1)]); ```javascript const person = { - firstName: 'Lydia', - lastName: 'Hallie', + firstName: "Lydia", + lastName: "Hallie", pet: { - name: 'Mara', - breed: 'Dutch Tulip Hound', + name: "Mara", + breed: "Dutch Tulip Hound", }, getFullName() { return `${this.firstName} ${this.lastName}`; @@ -3920,10 +3919,10 @@ console.log(member.getLastName?.()); ###### 120. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const groceries = ['banana', 'apple', 'peanuts']; +const groceries = ["banana", "apple", "peanuts"]; -if (groceries.indexOf('banana')) { - console.log('We have to buy bananas!'); +if (groceries.indexOf("banana")) { + console.log("We have to buy bananas!"); } else { console.log(`We don't have to buy bananas!`); } @@ -3979,10 +3978,10 @@ console.log(config.language); ###### 122. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const name = 'Lydia Hallie'; +const name = "Lydia Hallie"; -console.log(!typeof name === 'object'); -console.log(!typeof name === 'string'); +console.log(!typeof name === "object"); +console.log(!typeof name === "string"); ``` - A: `false` `true` @@ -4025,7 +4024,10 @@ add(4)(5)(6); #### āωāĻ¤ā§āϤāϰ: A -The `add` function returns an arrow function, which returns an arrow function, which returns an arrow function (still with me?). The first function receives an argument `x` with the value of `4`. We invoke the second function, which receives an argument `y` with the value `5`. Then we invoke the third function, which receives an argument `z` with the value `6`. When we're trying to access the value `x`, `y` and `z` within the last arrow function, the JS engine goes up the scope chain in order to find the values for `x` and `y` accordingly. This returns `4` `5` `6`. +`add` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧋ āĻĢāĻžāĻ‚āĻļāύ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ (āĻāϕ⧇ āĻŦāϞāĻž āĻšā§Ÿ curried function), āϝ⧇āϟāĻž āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧋ āĻĢāĻžāĻ‚āĻļāύ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇, āϝ⧇āϟāĻž āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧋ āĻĢāĻžāĻ‚āĻļāύ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ (āĻŽāĻžāĻĨāĻž āĻ–āĻžāϰāĻžāĻĒ āĻšāĻšā§āϛ⧇ āύāĻžāϤ⧋ đŸ¤¯)āĨ¤ ā§§āĻŽ āĻĢāĻžāĻ‚āĻļāύ āĻāĻ•āϟāĻŋ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āϰāĻŋāϏāĻŋāĻ­ āĻ•āϰ⧇ `x` āϝāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻšāϞ⧋ `4`āĨ¤ āφāĻŽāϰāĻž ⧍⧟ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻ•āϞ āĻ•āϰāĻŋ, āϝ⧇āϟāĻž āĻāĻ•āϟāĻŋ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āϰāĻŋāϏāĻŋāĻ­ āĻ•āϰ⧇ `y` āϝāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻšāϞ⧋ `5`āĨ¤ āĻāϰāĻĒāϰ āφāĻŽāϰāĻž ā§Šā§Ÿ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻ•āϞ āĻ•āϰāĻŋ, āϝ⧇āϟāĻž āĻāĻ•āϟāĻŋ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āϰāĻŋāϏāĻŋāĻ­ āĻ•āϰ⧇ `z` āϝāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻšāϞ⧋ `6`āĨ¤ āφāĻŽāϰāĻž āϝāĻ–āύ āĻļ⧇āώ āĻ…ā§āϝāĻžāϰ⧋ āĻĢāĻžāĻ‚āĻļāύ⧇ `x`, `y` āĻ“ `z` āĻ­ā§āϝāĻžāϞ⧁āϕ⧇ āĻāĻ•ā§āϏ⧇āϏ āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāĻ›āĻŋ, āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āχāĻžā§āϜāĻŋāύ `x` āĻ“ `y` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞ⧋āϰ āϜāĻ¨ā§āϝ āϤāĻžāĻĻ⧇āϰ āĻ…āĻŦāĻ¸ā§āĻĨāĻžāύ āĻ…āύ⧁āϏāĻžāϰ⧇ āĻ¸ā§āϕ⧋āĻĒ āĻšā§‡āχāύ⧇āϰ āωāĻĒāϰ⧇ āϝāĻžāĻšā§āϛ⧇āĨ¤ āϞāĻ— āĻ•āϰāϛ⧇ `4` `5` `6` āĻāĻŦāĻ‚ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇ `15`āĨ¤ + +> - āĻ•ā§āϝāĻžāϰāĻŋ āĻĢāĻžāĻ‚āĻļāύ (curried functions) āĻ•ā§āϞ⧋āϜāĻžāϰ ([closures](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures)) āĻāϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡ āĻāĻ•āĻžāϧāĻŋāĻ• āĻĢāĻžāĻ‚āĻļāύ āĻ•āϞ⧇āϰ āĻŽāĻ§ā§āϝ⧇ āĻ¸ā§āĻŸā§‡āϟ āĻŽā§‡āχāĻ¨ā§āĻŸā§‡āχāύ āĻ•āϰ⧇āĨ¤ āĻĒā§āϰāϤāĻŋāϟāĻŋ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻšāĻ“ā§ŸāĻž āĻĢāĻžāĻ‚āĻļāύ āϤāĻžāϰ āĻ¸ā§āϕ⧋āĻĒ āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇ āĻŽāύ⧇ āϰāĻžāϖ⧇āĨ¤ +> - āϝāĻ–āύ āφāĻĒāύāĻŋ `add(4)(5)(6)` āĻ•āϞ āĻ•āϰāϛ⧇āύ, āχāύāĻžāϰ āĻĢāĻžāĻ‚āĻļāύāϗ⧁āϞ⧋āϤ⧇ `x` āĻ“ `y` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āϝāĻĨāĻžāĻ•ā§āϰāĻŽā§‡, `4` āĻ“ `5` āĻāϰ āĻāĻ•ā§āϏ⧇āϏ āĻāĻ–āύ⧋ āĻĨāĻžāĻ•āϛ⧇, āϝāĻĻāĻŋāĻ“ āϤāĻžāϰāĻž āĻ­āĻŋāĻ¨ā§āύ āĻ•āύāĻŸā§āϝāĻžāĻ•ā§āϏ⧇ āϚāϞ⧇āĨ¤

@@ -4059,7 +4061,7 @@ async function* range(start, end) { #### āωāĻ¤ā§āϤāϰ: C -The generator function `range` returns an async object with promises for each item in the range we pass: `Promise{1}`, `Promise{2}`, `Promise{3}`. We set the variable `gen` equal to the async object, after which we loop over it using a `for await ... of` loop. We set the variable `item` equal to the returned Promise values: first `Promise{1}`, then `Promise{2}`, then `Promise{3}`. Since we're _awaiting_ the value of `item`, the resolved promise, the resolved _values_ of the promises get returned: `1`, `2`, then `3`. +āφāĻŽāϰāĻž āϝ⧇ āϰ⧇āĻžā§āϜāϟāĻŋ āĻĒāĻžāϏ āĻ•āϰāĻ›āĻŋ āϤāĻžāĻĻ⧇āϰ āĻĒā§āϰāϤāĻŋāϟāĻŋāϰ āϜāĻ¨ā§āϝ āĻœā§‡āύāĻžāϰ⧇āϟāϰ āĻĢāĻžāĻ‚āĻļāύ `range` āĻĒā§āϰāĻŽāĻŋāϏāϏāĻš āĻāĻ•āϟāĻŋ āĻāϏāĻŋāĻ™ā§āĻ• āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āσ `Promise{1}`, `Promise{2}`, `Promise{3}`āĨ¤ `gen` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞ āϏāĻŽāĻžāύ āϏ⧇āϟ āĻ•āϰāĻ›āĻŋ āĻāχ āĻāϏāĻŋāĻ™ā§āĻ• āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāĻŋāϕ⧇, āĻĒāϰāĻŦāĻ°ā§āϤāĻŋāϤ⧇ āϝ⧇āϟāĻžāϰ āωāĻĒāϰ āφāĻŽāϰāĻž `for await ... of` āϞ⧁āĻĒ āϚāĻžāϞāĻžāĻšā§āĻ›āĻŋāĨ¤ āĻāĻ–āĻžāύ⧇ `item` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞ āϏāĻŽāĻžāύ āϏ⧇āϟ āĻ•āϰāĻ›āĻŋ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻž āĻĒā§āϰāĻŽāĻŋāϏ āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞ⧋āϕ⧇āσ ā§§āĻŽā§‡ `Promise{1}`, āĻĒāϰāĻŦāĻ°ā§āϤāĻŋāϤ⧇ `Promise{2}`, āĻĒāϰāĻŦāĻ°ā§āϤāĻŋāϤ⧇ `Promise{3}`āĨ¤ āϝ⧇āĻšā§‡āϤ⧁ āφāĻŽāϰāĻž `item` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞ⧇āϰ āϜāĻ¨ā§āϝ _awaiting_ āĻ•āϰāĻ›āĻŋ, āϤāĻžāχ āĻĒā§āϰāĻŽāĻŋāϏ⧇āϰ āϰāĻŋāϏāĻ˛ā§āĻ­āĻĄ _āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞ⧋āχ_ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻšāĻšā§āϛ⧇āσ `1`, `2`, āĻ“ `3`āĨ¤

@@ -4086,7 +4088,7 @@ myFunc(1, 2, 3); #### āωāĻ¤ā§āϤāϰ: D -`myFunc` expects an object with properties `x`, `y` and `z` as its argument. Since we're only passing three separate numeric values (1, 2, 3) instead of one object with properties `x`, `y` and `z` ({x: 1, y: 2, z: 3}), `x`, `y` and `z` have their default value of `undefined`. +`myFunc` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āĻŸā§‡ āφāĻļāĻž āĻ•āϰāϛ⧇ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āϝāĻžāϰ `x`, `y` āĻ“ `z` āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϗ⧁āϞ⧋ āφāϛ⧇āĨ¤ āϝ⧇āĻšā§‡āϤ⧁ āφāĻŽāϰāĻž āĻāĻ•āϟāĻŋ `x`, `y` āĻ“ `z` āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϏāĻš āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤ⧇ ({x: 1, y: 2, z: 3}) āφāϞāĻžāĻĻāĻž āφāϞāĻĻāĻž āϏāĻ‚āĻ–ā§āϝāĻžāϏ⧁āϚāĻ• āĻ­ā§āϝāĻžāϞ⧁ (1, 2, 3) āĻĒāĻžāϏ āĻ•āϰāĻ›āĻŋ, `x`, `y` āĻ“ `z`āĻāϰ āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞ⧋ āϤāĻžāĻĻ⧇āϰ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻ­ā§āϝāĻžāϞ⧁ `undefined`-āχ āĻĨāĻžāĻ•āϛ⧇āĨ¤q

@@ -4097,14 +4099,14 @@ myFunc(1, 2, 3); ```javascript function getFine(speed, amount) { - const formattedSpeed = new Intl.NumberFormat('en-US', { - style: 'unit', - unit: 'mile-per-hour', + const formattedSpeed = new Intl.NumberFormat("en-US", { + style: "unit", + unit: "mile-per-hour", }).format(speed); - const formattedAmount = new Intl.NumberFormat('en-US', { - style: 'currency', - currency: 'USD', + const formattedAmount = new Intl.NumberFormat("en-US", { + style: "currency", + currency: "USD", }).format(amount); return `The driver drove ${formattedSpeed} and has to pay ${formattedAmount}`; @@ -4123,7 +4125,7 @@ console.log(getFine(130, 300)); #### āωāĻ¤ā§āϤāϰ: B -With the `Intl.NumberFormat` method, we can format numeric values to any locale. We format the numeric value `130` to the `en-US` locale as a `unit` in `mile-per-hour`, which results in `130 mph`. The numeric value `300` to the `en-US` locale as a `currency` in `USD` results in `$300.00`. +`Intl.NumberFormat` āĻŽā§‡āĻĨāĻĄ āĻŦā§āϝāĻžāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ āϏāĻ‚āĻ–ā§āϝāĻžāϏ⧁āϚāĻ• āĻ­ā§āϝāĻžāϞ⧁āϕ⧇ āϕ⧋āύ āĻāĻ•āϟāĻŋ āϞ⧋āĻ•āĻžāϞ⧇ āĻĢāϰāĻŽā§āϝāĻžāϟ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ āφāĻŽāϰāĻž āϏāĻ‚āĻ–ā§āϝāĻžāϏ⧁āϚāĻ• āĻ­ā§āϝāĻžāϞ⧁ `130` āϕ⧇ `unit` āĻšāĻŋāϏ⧇āĻŦ⧇ `mile-per-hour` āĻĻāĻŋā§Ÿā§‡ `en-US` āϞ⧋āĻ•āĻžāϞ⧇ āĻĢāϰāĻŽā§āϝāĻžāϟ āĻ•āϰ⧇āĻ›āĻŋ, āϝ⧇āϟāĻž āĻĢāϞāĻžāĻĢāϞ āĻĻāĻŋā§Ÿā§‡āϛ⧇ `130 mph`āĨ¤ āĻāĻ•āχāĻ­āĻžāĻŦ⧇ āϏāĻ‚āĻ–ā§āϝāĻžāϏ⧁āϚāĻ• āĻ­ā§āϝāĻžāϞ⧁ `300` āϕ⧇ `currency` āĻšāĻŋāϏ⧇āĻŦ⧇ `USD` āĻĻāĻŋā§Ÿā§‡ `en-US` āϞ⧋āĻ•āĻžāϞ⧇ āĻĢāϰāĻŽā§āϝāĻžāϟ āĻ•āϰ⧇āĻ›āĻŋ āϝ⧇āϟāĻžāϰ āĻĢāϞāĻžāĻĢāϞ āĻšā§Ÿ `$300.00`āĨ¤

@@ -4133,8 +4135,8 @@ With the `Intl.NumberFormat` method, we can format numeric values to any locale. ###### 127. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const spookyItems = ['đŸ‘ģ', '🎃', '🕸']; -({ item: spookyItems[3] } = { item: '💀' }); +const spookyItems = ["đŸ‘ģ", "🎃", "🕸"]; +({ item: spookyItems[3] } = { item: "💀" }); console.log(spookyItems); ``` @@ -4149,7 +4151,7 @@ console.log(spookyItems); #### āωāĻ¤ā§āϤāϰ: B -By destructuring objects, we can unpack values from the right-hand object, and assign the unpacked value to the value of the same property name on the left-hand object. In this case, we're assigning the value "💀" to `spookyItems[3]`. This means that we're modifying the `spookyItems` array, we're adding the "💀" to it. When logging `spookyItems`, `["đŸ‘ģ", "🎃", "🕸", "💀"]` gets logged. +āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻĄāĻŋāĻ¸ā§āĻŸā§āϰāĻžāĻ•āϚāĻžāϰāĻŋāĻ‚ ([āĻĄāĻŋāĻ¸ā§āĻŸā§āϰāĻžāĻ•āϚāĻžāϰāĻŋāĻ‚ āĻ…ā§āϝāĻžāϏāĻžāχāύāĻŽā§‡āĻ¨ā§āϟ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment)) āĻāϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡, āĻĄāĻžāύāĻĒāĻ•ā§āώ⧇āϰ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞ⧋āϕ⧇ āĻŦ⧇āϰ āĻ•āϰ⧇ āĻŦāĻžāĻŽāĻĒāĻ•ā§āώ⧇āϰ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻāĻ•āχ āύāĻžāĻŽā§‡āϰ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻĻāĻŋā§Ÿā§‡ āĻ…ā§āϝāĻžāϏāĻžāχāύ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āφāĻŽāϰāĻž "💀" āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋāϕ⧇ `spookyItems[3]`-āϤ⧇ āĻ…ā§āϝāĻžāϏāĻžāχāύ āĻ•āϰāĻ›āĻŋāĨ¤ āĻāϰ āĻŽāĻžāύ⧇ āĻšāϞ⧋, "💀" āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋāϕ⧇ āϝ⧁āĻ•ā§āϤ āĻ•āϰ⧇ āφāĻŽāϰāĻž `spookyItems` āĻ…ā§āϝāĻžāϰ⧇āϕ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇āĻ›āĻŋāĨ¤ āϤāĻžāχ `spookyItems` āϕ⧇ āϞāĻ— āĻ•āϰāĻžā§Ÿ `["đŸ‘ģ", "🎃", "🕸", "💀"]` āϞāĻ— āĻšā§Ÿā§‡āϛ⧇āĨ¤

@@ -4159,7 +4161,7 @@ By destructuring objects, we can unpack values from the right-hand object, and a ###### 128. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const name = 'Lydia Hallie'; +const name = "Lydia Hallie"; const age = 21; console.log(Number.isNaN(name)); @@ -4179,9 +4181,9 @@ console.log(isNaN(age)); #### āωāĻ¤ā§āϤāϰ: C -With the `Number.isNaN` method, you can check if the value you pass is a _numeric value_ and equal to `NaN`. `name` is not a numeric value, so `Number.isNaN(name)` returns `false`. `age` is a numeric value, but is not equal to `NaN`, so `Number.isNaN(age)` returns `false`. +`Number.isNaN` āĻŽā§‡āĻĨāĻĄā§‡āϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡, āφāĻĒāύāĻŋ āĻšā§‡āĻ• āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āύ āϝ⧇ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āφāĻĒāύāĻŋ āĻĒāĻžāϏ āĻ•āϰāϛ⧇āύ āϏ⧇āϟāĻž _āϏāĻ‚āĻ–ā§āϝāĻžāϏ⧁āϚāĻ• āĻ­ā§āϝāĻžāϞ⧁_ āĻāĻŦāĻ‚ _`NaN`_ āĻāϰ āϏāĻŽāĻžāύ āĻšāĻšā§āϛ⧇ āĻ•āĻŋāύāĻžāĨ¤ `name` āϏāĻ‚āĻ–ā§āϝāĻžāϏ⧁āϚāĻ• āĻ­ā§āϝāĻžāϞ⧁ āύ⧟, āϤāĻžāχ `Number.isNaN(name)` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇ `false`āĨ¤ `age` āϏāĻ‚āĻ–ā§āϝāĻžāϏ⧁āϚāĻ• āĻ­ā§āϝāĻžāϞ⧁ āĻ•āĻŋāĻ¨ā§āϤ⧁ `NaN` āĻāϰ āϏāĻŽāĻžāύ āύ⧟, āϤāĻžāχ `Number.isNaN(age)` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇ `false`āĨ¤ -With the `isNaN` method, you can check if the value you pass is not a number. `name` is not a number, so `isNaN(name)` returns true. `age` is a number, so `isNaN(age)` returns `false`. +āĻ…āĻ¨ā§āϝāĻĻāĻŋāϕ⧇ `isNaN` āĻŽā§‡āĻĨāĻĄā§‡āϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡, āφāĻĒāύāĻŋ āϕ⧇āĻŦāϞ āĻšā§‡āĻ• āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āύ āϝ⧇ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āφāĻĒāύāĻŋ āĻĒāĻžāϏ āĻ•āϰāϛ⧇āύ āϏ⧇āϟāĻž āϕ⧋āύ _āϏāĻ‚āĻ–ā§āϝāĻž āύ⧟_ āĻ•āĻŋāύāĻžāĨ¤ `name` āϕ⧋āύ āϏāĻ‚āĻ–ā§āϝāĻž āύ⧟, āϤāĻžāχ `isNaN(name)` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇ `true`āĨ¤ `age` āĻāĻ•āϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻž, āϤāĻžāχ `isNaN(age)` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇ `false`

@@ -4195,7 +4197,7 @@ const randomValue = 21; function getInfo() { console.log(typeof randomValue); - const randomValue = 'Lydia Hallie'; + const randomValue = "Lydia Hallie"; } getInfo(); @@ -4211,7 +4213,9 @@ getInfo(); #### āωāĻ¤ā§āϤāϰ: D -Variables declared with the `const` keyword are not referenceable before their initialization: this is called the _temporal dead zone_. In the `getInfo` function, the variable `randomValue` is scoped in the functional scope of `getInfo`. On the line where we want to log the value of `typeof randomValue`, the variable `randomValue` isn't initialized yet: a `ReferenceError` gets thrown! The engine didn't go down the scope chain since we declared the variable `randomValue` in the `getInfo` function. +`const` (āĻ“ `let`) āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄ āĻĻāĻŋā§Ÿā§‡ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰāĻž āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞāϗ⧁āϞ⧋ āϝ⧇ āϞāĻžāχāύ⧇ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ (āχāύāĻŋāĻļāĻŋ⧟āĻžāϞāĻžāχāϜ) āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇ āϤāĻžāϰ āφāϗ⧇ āĻāĻĻ⧇āϰāϕ⧇ āĻāĻ•ā§āϏ⧇āϏ (āϰāĻŋāĻĄ/āϰāĻžāχāϟ) āĻŦāĻž āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āĻ•āϰāĻž āϝāĻžā§Ÿ āύāĻžāĨ¤ āĻāϟāĻžāϕ⧇ **"āĻŸā§‡āĻŽā§āĻĒā§‹āϰāĻžāϞ āĻĄā§‡āĻĄ āĻœā§‹āύ"** āĻŦāϞāĻž āĻšā§ŸāĨ¤ āϤāĻžāχ āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞāϕ⧇ āχāύāĻŋāĻļāĻŋ⧟āĻžāϞāĻžāχāĻœā§‡āĻļāύ⧇āϰ āφāϗ⧇ āĻāĻ•ā§āϏ⧇āϏ āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāĻž āĻšāϞ⧇ āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ `ReferenceError` āĻĻā§‡ā§ŸāĨ¤ + +`getInfo` āĻĢāĻžāĻ‚āĻļāύ⧇āϰ `randomValue` āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞāϟāĻŋāϰ āĻ¸ā§āϕ⧋āĻĒ āĻšāĻšā§āϛ⧇ āϤāĻžāϰ āĻĢāĻžāĻ‚āĻļāύāĻžāϞ āĻ¸ā§āϕ⧋āĻĒ - `getInfo`āĨ¤ āϝ⧇ āϞāĻžāχāύ⧇ āφāĻŽāϰāĻž `typeof randomValue` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇ āϞāĻ— āĻ•āϰāĻ›āĻŋ, āϤāĻ–āύ⧋ `randomValue` āχāύāĻŋāĻļāĻŋ⧟āĻžāϞāĻžāχāϜ āĻšā§ŸāύāĻŋāσ āĻāĻ•āϟāĻŋ `ReferenceError` āĻšāĻšā§āϛ⧇! āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āχāĻžā§āϜāĻŋāύ āĻ¸ā§āϕ⧋āĻĒ āĻšā§‡āχāύ⧇ āϖ⧁āρāĻœā§‡ āĻĻ⧇āĻ–āϛ⧇ āύāĻž āϝ⧇āĻšā§‡āϤ⧁ āφāĻŽāϰāĻž `randomValue` āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞāϟāĻŋāϕ⧇ `getInfo` āĻĢāĻžāĻ‚āĻļāύ⧇āχ āĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ āĻ•āϰ⧇āĻ›āĻŋāĨ¤

@@ -4221,7 +4225,7 @@ Variables declared with the `const` keyword are not referenceable before their i ###### 130. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const myPromise = Promise.resolve('Woah some cool data'); +const myPromise = Promise.resolve("Woah some cool data"); (async () => { try { @@ -4229,7 +4233,7 @@ const myPromise = Promise.resolve('Woah some cool data'); } catch { throw new Error(`Oops didn't work`); } finally { - console.log('Oh finally!'); + console.log("Oh finally!"); } })(); ``` @@ -4244,7 +4248,7 @@ const myPromise = Promise.resolve('Woah some cool data'); #### āωāĻ¤ā§āϤāϰ: C -In the `try` block, we're logging the awaited value of the `myPromise` variable: `"Woah some cool data"`. Since no errors were thrown in the `try` block, the code in the `catch` block doesn't run. The code in the `finally` block _always_ runs, `"Oh finally!"` gets logged. +`try` āĻŦā§āϞāϕ⧇, āφāĻŽāϰāĻž `myPromise` āϭ⧇āϰāĻŋāϝāĻŧ⧇āĻŦāϞ⧇āϰ āĻ…āĻĒ⧇āĻ•ā§āώāĻŋāϤ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āϞāĻ— āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāĻ›āĻŋ: `"Woah some cool data"`āĨ¤ āϝ⧇āĻšā§‡āϤ⧁ `try` āĻŦā§āϞāϕ⧇ āϕ⧋āύ⧋ āĻāϰāϰ āĻĨā§āϰ⧋ āĻšāϝāĻŧāύāĻŋ, `catch` āĻŦā§āϞāϕ⧇āϰ āϕ⧋āĻĄ āϰāĻžāύ āĻšāϝāĻŧ āύāĻžāĨ¤ `finally` āĻŦā§āϞāϕ⧇āϰ āϕ⧋āĻĄ _āϏāĻŦāϏāĻŽāϝāĻŧāχ_ āϰāĻžāύ āĻšāϝāĻŧ, āϤāĻžāχ `"Oh finally!"` āϞāĻ— āĻšāϝāĻŧāĨ¤

@@ -4254,7 +4258,7 @@ In the `try` block, we're logging the awaited value of the `myPromise` variable: ###### 131. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const emojis = ['đŸĨ‘', ['✨', '✨', ['🍕', '🍕']]]; +const emojis = ["đŸĨ‘", ["✨", "✨", ["🍕", "🍕"]]]; console.log(emojis.flat(1)); ``` @@ -4269,7 +4273,7 @@ console.log(emojis.flat(1)); #### āωāĻ¤ā§āϤāϰ: B -With the `flat` method, we can create a new, flattened array. The depth of the flattened array depends on the value that we pass. In this case, we passed the value `1` (which we didn't have to, that's the default value), meaning that only the arrays on the first depth will be concatenated. `['đŸĨ‘']` and `['✨', '✨', ['🍕', '🍕']]` in this case. Concatenating these two arrays results in `['đŸĨ‘', '✨', '✨', ['🍕', '🍕']]`. +`flat` āĻĒāĻĻā§āϧāϤāĻŋāϰ āϏāĻžāĻšāĻžāĻ¯ā§āϝ⧇, āφāĻŽāϰāĻž āĻāĻ•āϟāĻŋ āύāϤ⧁āύ, āϏāĻŽāϤāϞāĻ•ā§ƒāϤ āĻ…ā§āϝāĻžāϰ⧇ āϤ⧈āϰāĻŋ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ āϏāĻŽāϤāϞāĻ•ā§ƒāϤ āĻ…ā§āϝāĻžāϰ⧇āϰ āĻ—āĻ­ā§€āϰāϤāĻž āύāĻŋāĻ°ā§āĻ­āϰ āĻ•āϰ⧇ āϝ⧇ āĻŽāĻžāύāϟāĻŋ āφāĻŽāϰāĻž āĻĒāĻžāϏ āĻ•āϰāĻŋ āϤāĻžāϰ āωāĻĒāϰāĨ¤ āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āφāĻŽāϰāĻž āĻŽāĻžāύ `1` āĻĒāĻžāϏ āĻ•āϰ⧇āĻ›āĻŋ (āϝāĻž āφāĻŽāĻžāĻĻ⧇āϰ āĻĒāĻžāϏ āύāĻž āĻ•āϰāϞ⧇āĻ“ āĻšāϤ, āĻāϟāĻŋ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻŽāĻžāύ), āĻāϰ āĻ…āĻ°ā§āĻĨ āĻšāϞ āϕ⧇āĻŦāϞāĻŽāĻžāĻ¤ā§āϰ āĻĒā§āϰāĻĨāĻŽ āĻ¸ā§āϤāϰ⧇āϰ āĻ…ā§āϝāĻžāϰ⧇āϗ⧁āϞāĻŋ āϏāĻ‚āϝ⧁āĻ•ā§āϤ āĻšāĻŦ⧇āĨ¤ āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ `['đŸĨ‘']` āĻāĻŦāĻ‚ `['✨', '✨', ['🍕', '🍕']]`āĨ¤ āĻāχ āĻĻ⧁āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇ āϏāĻ‚āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻžāϰ āĻĢāϞ⧇ `['đŸĨ‘', '✨', '✨', ['🍕', '🍕']]` āĻĒāĻžāĻ“āϝāĻŧāĻž āϝāĻžāϝāĻŧāĨ¤

@@ -4309,13 +4313,13 @@ console.log(counterOne.count); #### āωāĻ¤ā§āϤāϰ: D -`counterOne` is an instance of the `Counter` class. The counter class contains a `count` property on its constructor, and an `increment` method. First, we invoked the `increment` method twice by calling `counterOne.increment()`. Currently, `counterOne.count` is `2`. +`counterOne` āĻšāϞ `Counter` āĻ•ā§āϞāĻžāϏ⧇āϰ āĻāĻ•āϟāĻŋ āχāύāĻ¸ā§āĻŸā§āϝāĻžāĻ¨ā§āϏāĨ¤ `Counter` āĻ•ā§āϞāĻžāϏ⧇āϰ āĻ•āύāĻ¸ā§āĻŸā§āϰāĻžāĻ•ā§āϟāϰ⧇ āĻāĻ•āϟāĻŋ `count` āĻĒā§āϰāĻĒāĻžāĻ°ā§āϟāĻŋ āĻāĻŦāĻ‚ āĻāĻ•āϟāĻŋ `increment` āĻŽā§‡āĻĨāĻĄ āϰāϝāĻŧ⧇āϛ⧇āĨ¤ āĻĒā§āϰāĻĨāĻŽā§‡, āφāĻŽāϰāĻž `counterOne.increment()` āĻ•āϞ āĻ•āϰ⧇ `increment` āĻŽā§‡āĻĨāĻĄ āĻĻ⧁'āĻŦāĻžāϰ āĻ•āϞ āĻ•āϰ⧇āĻ›āĻŋāĨ¤ āĻŦāĻ°ā§āϤāĻŽāĻžāύ⧇, `counterOne.count` āĻšāϞ `2`āĨ¤ -Then, we create a new variable `counterTwo`, and set it equal to `counterOne`. Since objects interact by reference, we're just creating a new reference to the same spot in memory that `counterOne` points to. Since it has the same spot in memory, any changes made to the object that `counterTwo` has a reference to, also apply to `counterOne`. Currently, `counterTwo.count` is `2`. +āϤāĻžāϰāĻĒāϰ, āφāĻŽāϰāĻž āĻāĻ•āϟāĻŋ āύāϤ⧁āύ āϭ⧇āϰāĻŋāϝāĻŧ⧇āĻŦāϞ `counterTwo` āϤ⧈āϰāĻŋ āĻ•āϰāĻŋ āĻāĻŦāĻ‚ āĻāϟāĻŋāϕ⧇ `counterOne` āĻāϰ āϏāĻŽāĻžāύ āϏ⧇āϟ āĻ•āϰāĻŋāĨ¤ āϝ⧇āĻšā§‡āϤ⧁ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϗ⧁āϞāĻŋ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āĻĻā§āĻŦāĻžāϰāĻž āχāĻ¨ā§āϟāĻžāϰāĻ…ā§āϝāĻžāĻ•ā§āϟ āĻ•āϰ⧇, āφāĻŽāϰāĻž āϕ⧇āĻŦāϞ `counterOne` āϝ⧇ āĻŽā§‡āĻŽāϰāĻŋāϰ āϞ⧋āϕ⧇āĻļāύ⧇ āύāĻŋāĻ°ā§āĻĻ⧇āĻļ āĻ•āϰ⧇ āϤāĻžāϰ āĻāĻ•āϟāĻŋ āύāϤ⧁āύ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āϤ⧈āϰāĻŋ āĻ•āϰāĻ›āĻŋāĨ¤ āϝ⧇āĻšā§‡āϤ⧁ āĻāϟāĻŋ āĻāĻ•āχ āĻŽā§‡āĻŽāϰāĻŋ āϞ⧋āϕ⧇āĻļāύ⧇ āύāĻŋāĻ°ā§āĻĻ⧇āĻļ āĻ•āϰ⧇, āϤāĻžāχ `counterTwo` āϝ⧇āχ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϟāĻŋāϰ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āĻĻ⧇āϝāĻŧ āϤāĻžāϤ⧇ āĻ•āϰāĻž āϝ⧇āϕ⧋āύ⧋ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ `counterOne` āĻāϰ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇āĻ“ āĻĒā§āϰāϝ⧋āĻœā§āϝ āĻšāĻŦ⧇āĨ¤ āĻŦāĻ°ā§āϤāĻŽāĻžāύ⧇, `counterTwo.count` āĻšāϞ `2`āĨ¤ -We invoke `counterTwo.increment()`, which sets `count` to `3`. Then, we log the count on `counterOne`, which logs `3`. +āφāĻŽāϰāĻž `counterTwo.increment()` āĻ•āϞ āĻ•āϰāĻŋ, āϝāĻž `count` āϕ⧇ āϏ⧇āϟ āĻ•āϰ⧇ `3`āĨ¤ āϤāĻžāϰāĻĒāϰ, āφāĻŽāϰāĻž `counterOne` āĻāϰ `count` āϞāĻ— āĻ•āϰāĻŋ, āϝāĻž āϞāĻ— āĻ•āϰ⧇ `3`āĨ¤ @@ -4327,19 +4331,19 @@ We invoke `counterTwo.increment()`, which sets `count` to `3`. Then, we log the ###### 133. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const myPromise = Promise.resolve(Promise.resolve('Promise')); +const myPromise = Promise.resolve(Promise.resolve("Promise")); function funcOne() { - setTimeout(() => console.log('Timeout 1!'), 0); + setTimeout(() => console.log("Timeout 1!"), 0); myPromise.then((res) => res).then((res) => console.log(`${res} 1!`)); - console.log('Last line 1!'); + console.log("Last line 1!"); } async function funcTwo() { const res = await myPromise; console.log(`${res} 2!`); - setTimeout(() => console.log('Timeout 2!'), 0); - console.log('Last line 2!'); + setTimeout(() => console.log("Timeout 2!"), 0); + console.log("Last line 2!"); } funcOne(); @@ -4356,19 +4360,19 @@ funcTwo(); #### āωāĻ¤ā§āϤāϰ: C -First, we invoke `funcOne`. On the first line of `funcOne`, we call the _asynchronous_ `setTimeout` function, from which the callback is sent to the Web API. (see my article on the event loop here.) +āĻĒā§āϰāĻĨāĻŽā§‡, āφāĻŽāϰāĻž `funcOne` āĻĢāĻžāĻ‚āĻļāύ āϚāĻžāϞāĻŋā§Ÿā§‡āĻ›āĻŋāĨ¤ `funcOne` āĻāϰ ā§§āĻŽ āϞāĻžāχāύ⧇ āφāĻŽāϰāĻž _āĻ…ā§āϝāĻžāϏāĻŋāĻ™ā§āĻ•ā§āϰ⧋āύāĻžāϏ_ `setTimeout` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻ•āϞ āĻ•āϰāĻ›āĻŋ, āϝ⧇āĻ–āĻžāύ āĻĨ⧇āϕ⧇ āĻ•āϞāĻŦā§āϝāĻžāĻ•āϟāĻŋ Web API āĻ āĻĒāĻžāĻ āĻžāύ⧋ āĻšā§Ÿā§‡āϛ⧇āĨ¤ (āχāϭ⧇āĻ¨ā§āϟ āϞ⧁āĻĒ⧇āϰ āφāĻ°ā§āϟāĻŋāĻ•ā§āϝāĻžāϞāϟāĻŋ āĻĒ⧜⧁āύ āĻāĻ–āĻžāύ āĻĨ⧇āϕ⧇.) -Then we call the `myPromise` promise, which is an _asynchronous_ operation. Pay attention, that now only the first then clause was added to the microtask queue. +āĻĒāϰāĻŦāĻ°ā§āϤāĻŋāϤ⧇ āφāĻŽāϰāĻž `myPromise` āĻĒā§āϰāĻŽāĻŋāϏāϟāĻŋ āĻ•āϞ āĻ•āϰ⧇āĻ›āĻŋ āϝ⧇āϟāĻž _āĻ…ā§āϝāĻžāϏāĻŋāĻ™ā§āĻ•ā§āϰ⧋āύāĻžāϏ_ āĻ…āĻĒāĻžāϰ⧇āĻļāύāĨ¤ āĻŽāύ⧋āϝ⧋āĻ— āĻĻāĻŋāύ, āĻāĻ–āύ āϕ⧇āĻŦāϞ `.then()` āĻšā§‡āχāύ⧇āϰ ā§§āĻŽ āĻ…āĻ‚āĻļāϟāĻŋ āĻŽāĻžāχāĻ•ā§āϰ⧋āϟāĻžāĻ¸ā§āĻ• āĻ•āĻŋāωāϤ⧇ āϝ⧁āĻ•ā§āϤ āĻšā§Ÿā§‡āϛ⧇āĨ¤ -Both the promise and the timeout are asynchronous operations, the function keeps on running while it's busy completing the promise and handling the `setTimeout` callback. This means that `Last line 1!` gets logged first, since this is not an asynchonous operation. +āĻĒā§āϰāĻŽāĻŋāϏ āĻ“ āϟāĻžāχāĻŽ-āφāωāϟ āĻĻ⧁āĻŸā§‹āχ _āĻ…ā§āϝāĻžāϏāĻŋāĻ™ā§āĻ•ā§āϰ⧋āύāĻžāϏ_ āĻ…āĻĒāĻžāϰ⧇āĻļāύ, āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āϚāϞāϤ⧇āχ āĻĨāĻžāϕ⧇ āϝāĻ–āύ āϏ⧇ āĻĒā§āϰāĻŽāĻŋāϏ āϏāĻŽāĻžāϧāĻžāύ āĻāĻŦāĻ‚ āϟāĻžāχāĻŽ-āφāωāϟ āĻ•āϞāĻŦā§āϝāĻžāĻ• āĻšā§āϝāĻžāĻ¨ā§āĻĄā§‡āϞ āĻ•āϰāϤ⧇ āĻĨāĻžāϕ⧇āĨ¤ āĻāϰ āĻŽāĻžāύ⧇ āĻšāϞ⧋ `Last line 1!` āϞāĻ— āĻšāĻšā§āϛ⧇ āĻĒā§āϰāĻĨāĻŽā§‡, āϝ⧇āĻšā§‡āϤ⧁ āĻāϟāĻž āϕ⧋āύ _āĻ…ā§āϝāĻžāϏāĻŋāĻ™ā§āĻ•ā§āϰ⧋āύāĻžāϏ_ āĻ…āĻĒāĻžāϰ⧇āĻļāύ āύ⧟āĨ¤ -Since the callstack is not empty yet, the `setTimeout` function and promise in `funcOne` cannot get added to the callstack yet. +āϝ⧇āĻšā§‡āϤ⧁ āĻ•āϞāĻ¸ā§āĻŸā§āϝāĻžāĻ• āĻāĻ–āύ⧋ āĻ–āĻžāϞāĻŋ āύ⧟ āϤāĻžāχ `funcOne` āĻāϰ `setTimeout` āĻĢāĻžāĻ‚āĻļāύ āĻ“ `myPromise` āĻĒā§āϰāĻŽāĻŋāϏ āϤāĻ–āύ⧋ āĻ•āϞāĻ¸ā§āĻŸā§āϝāĻžāĻ• āĻ āφāϏāϤ⧇ āĻĒāĻžāϰ⧇ āύāĻžāĨ¤ -In `funcTwo`, the variable `res` gets `Promise` because `Promise.resolve(Promise.resolve('Promise'))` is equivalent to `Promise.resolve('Promise')` since resolving a promise just resolves it's value. The `await` in this line stops the execution of the function until it receives the resolution of the promise and then keeps on running synchronously until completion, so `Promise 2!` and then `Last line 2!` are logged and the `setTimeout` is sent to the Web API. If the first then clause in `funcOne` had its own log statement, it would be printed before `Promise 2!`. Howewer, it executed silently and put the second then clause in microtask queue. So, the second clause will be printed after `Promise 2!`. +`funcTwo` āĻ, `res` āϭ⧟āĻžāĻ°ā§‡ā§Ÿā§‡āĻŦāϞāϟāĻŋ āĻāĻ•āϟāĻŋ `Promise` āĻĒāĻžāĻšā§āϛ⧇ āĻ•āĻžāϰāύ `Promise.resolve(Promise.resolve('Promise'))` āĻāϰ āϏāĻŽāĻŽāĻžāύ āĻšāϞ⧋ `Promise.resolve('Promise')` āϝ⧇āĻšā§‡āϤ⧁ āĻāĻ•āϟāĻŋ āĻĒā§āϰāĻŽāĻŋāϏ āϏāĻŽāĻžāϧāĻžāύ āĻ•āϰāĻž āĻŽāĻžāύ⧇ āĻšāϞ⧋ āĻāϰ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋāϕ⧇āχ āϏāĻŽāĻžāϧāĻžāύ āĻ•āϰāĻžāĨ¤ `await` āĻāϰ āϜāĻ¨ā§āϝ āĻāχ āϞāĻžāχāύ⧇ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋāϰ āĻāĻ•ā§āϏāĻŋāĻ•āĻŋāωāĻļāύ āĻĨ⧇āĻŽā§‡ āĻĨāĻžāĻ•āĻŦ⧇ āϝāϤāĻ•ā§āώāĻŖ āĻĒāĻ°ā§āϝāĻ¨ā§āϤ āύāĻž āϏ⧇ āĻĒā§āϰāĻŽāĻŋāϏ āϏāĻŽāĻžāϧāĻžāύ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāĻšā§āϛ⧇ āĻāĻŦāĻ‚ āϏāĻŋāĻ™ā§āĻ•ā§āϰāύāĻžāϏāĻ­āĻžāĻŦ⧇ āĻļ⧇āώ āĻšāĻ“ā§ŸāĻž āĻĒāĻ°ā§āϝāĻ¨ā§āϤ āϚāϞāϤ⧇ āĻĨāĻžāϕ⧇, āϤāĻžāχ `Promise 2!` āĻ“ āĻāϰ āĻĒāϰ⧇ `Last line 2!` āϞāĻ— āĻšā§Ÿ āĻāĻŦāĻ‚ `setTimeout` Web API āϕ⧇ āĻĒāĻžāĻ āĻžāύ⧋ āĻšā§ŸāĨ¤ āϝāĻĻāĻŋ `funcOne` āĻĢāĻžāĻ‚āĻļāύ⧇ `.then()` āĻāϰ ā§§āĻŽ āĻ…āĻ‚āĻļ āύāĻŋāĻœā§‡āϰ āϕ⧋āύ āϞāĻ— āĻ¸ā§āĻŸā§‡āϟāĻŽā§‡āĻ¨ā§āϟ āĻĨāĻžāĻ•āϤ, āϏ⧇āϟāĻž `Promise 2!` āĻāϰ āφāϗ⧇ āĻĒā§āϰāĻŋāĻ¨ā§āϟ āĻšāϤāĨ¤ āϝāĻžāχ āĻšā§‹āĻ•, āĻāϟāĻž āϚ⧁āĻĒāϚāĻžāĻĒ āĻāĻ•ā§āϏāĻŋāĻ•āĻŋāωāϟ āĻšā§Ÿ āĻāĻŦāĻ‚ `.then()` āĻāϰ ⧍⧟ āĻ…āĻ‚āĻļāϕ⧇ āĻŽāĻžāχāĻ•ā§āϰ⧋āϟāĻžāĻ¸ā§āĻ• āĻ•āĻŋāωāϤ⧇ āĻĒāĻžāĻ āĻŋā§Ÿā§‡ āĻĻā§‡ā§ŸāĨ¤ āϤāĻžāχ, ⧍⧟ āĻ…āĻ‚āĻļāϟāĻŋ `Promise 2!` āĻāϰ āĻĒāϰ⧇āχ āĻĒā§āϰāĻŋāĻ¨ā§āϟ āĻšāĻŦ⧇āĨ¤ -Then the call stack is empty. Promises are _microtasks_ so they are resolved first when the call stack is empty so `Promise 1!` gets to be logged. +āĻĒāϰ⧇āϰ āϧāĻžāĻĒ⧇, āĻ•āϞ āĻ¸ā§āĻŸā§āϝāĻžāĻ• āĻ–āĻžāϞāĻŋāĨ¤ āĻĒā§āϰāĻŽāĻŋāϏāϗ⧁āϞ⧋ _āĻŽāĻžāχāĻ•ā§āϰ⧋āϟāĻžāĻ¸ā§āĻ•_ āĻĢāϞ⧇ āϤāĻžāρāϰāĻž āĻĒā§āϰāĻĨāĻŽā§‡ āϰāĻŋāϏāϞāĻ­ āĻšāĻŦ⧇ āϝāĻ–āύ āĻ•āϞ āĻ¸ā§āĻŸā§āϝāĻžāĻ• āĻ–āĻžāϞāĻŋ āĻĨāĻžāĻ•āĻŦ⧇ āϤāĻžāχ `Promise 1!` āϞāĻ— āĻšā§Ÿā§‡āϛ⧇āĨ¤ -Now, since `funcTwo` popped off the call stack, the call stack is empty. The callbacks waiting in the queue (`() => console.log("Timeout 1!")` from `funcOne`, and `() => console.log("Timeout 2!")` from `funcTwo`) get added to the call stack one by one. The first callback logs `Timeout 1!`, and gets popped off the stack. Then, the second callback logs `Timeout 2!`, and gets popped off the stack. +āĻāĻ–āύ āϝ⧇āĻšāϤ⧁ `funcTwo` āĻ•āϞ āĻ¸ā§āĻŸā§āϝāĻžāĻ• āĻĨ⧇āϕ⧇ āϰ⧇āĻŦ āĻšā§Ÿā§‡ āϝāĻžā§Ÿ, āĻ•āϞ āĻ¸ā§āĻŸā§āϝāĻžāĻ• āĻ–āĻžāϞāĻŋ āĻĨāĻžāĻ•āϛ⧇āĨ¤ āĻ•āĻŋāωāϤ⧇ āϝ⧇ āĻ•āϞāĻŦā§āϝāĻžāĻ•āϗ⧁āϞāĻŋ āĻ…āĻĒ⧇āĻ•ā§āώāĻž āĻ•āϰāϛ⧇ (`funcOne` āĻāϰ - `() => console.log("Timeout 1!")` āĻāĻŦāĻ‚ `funcTwo` āĻāϰ `() => console.log("Timeout 2!")`) āϤāĻžāϰāĻž āĻāϕ⧇āϰ āĻĒāϰ āĻāĻ• āĻ•āϞ āĻ¸ā§āĻŸā§āϝāĻžāĻ• āĻ āϝ⧁āĻ•ā§āϤ āĻšā§ŸāĨ¤ ā§§āĻŽ āĻ•āϞāĻŦā§āϝāĻžāĻ• āϞāĻ— āĻ•āϰ⧇ `Timeout 1!`, āĻāĻŦāĻ‚ āĻ•āϞ āĻ¸ā§āĻŸā§āϝāĻžāĻ• āĻĨ⧇āϕ⧇ āϰ⧇āĻŦ āĻšā§Ÿā§‡ āϝāĻžā§ŸāĨ¤ āĻāϰāĻĒāϰ, ⧍⧟ āĻ•āϞāĻŦā§āϝāĻžāĻ• āϞāĻ— āĻ•āϰ⧇ `Timeout 2!`, āĻāĻŦāĻ‚ āĻ•āϞ āĻ¸ā§āĻŸā§āϝāĻžāĻ• āĻĨ⧇āϕ⧇ āϰ⧇āĻŦ āĻšā§Ÿā§‡ āϝāĻžā§ŸāĨ¤

@@ -4384,7 +4388,7 @@ export default function sum(x) { } // index.js -import * as sum from './sum'; +import * as sum from "./sum"; ``` - A: `sum(4)` @@ -4401,12 +4405,12 @@ With the asterisk `*`, we import all exported values from that file, both defaul ```javascript // info.js -export const name = 'Lydia'; +export const name = "Lydia"; export const age = 21; -export default 'I love JavaScript'; +export default "I love JavaScript"; // index.js -import * as info from './info'; +import * as info from "./info"; console.log(info); ``` @@ -4437,13 +4441,13 @@ We can invoke this function, by calling `sum.default` ```javascript const handler = { - set: () => console.log('Added a new property!'), - get: () => console.log('Accessed a property!'), + set: () => console.log("Added a new property!"), + get: () => console.log("Accessed a property!"), }; const person = new Proxy({}, handler); -person.name = 'Lydia'; +person.name = "Lydia"; person.name; ``` @@ -4473,7 +4477,7 @@ Then, we access a property value on the proxy object, and the `get` property on ###### 136. Which of the following will modify the `person` object? ```javascript -const person = { name: 'Lydia Hallie' }; +const person = { name: "Lydia Hallie" }; Object.seal(person); ``` @@ -4501,9 +4505,9 @@ However, you can still modify the value of existing properties. ```javascript const person = { - name: 'Lydia Hallie', + name: "Lydia Hallie", address: { - street: '100 Main St', + street: "100 Main St", }, }; @@ -4603,8 +4607,8 @@ In ES2020, we can add private variables in classes by using the `#`. We cannot a ```javascript const teams = [ - { name: 'Team 1', members: ['Paul', 'Lisa'] }, - { name: 'Team 2', members: ['Laura', 'Tim'] }, + { name: "Team 1", members: ["Paul", "Lisa"] }, + { name: "Team 2", members: ["Laura", "Tim"] }, ]; function* getMembers(members) { @@ -4647,8 +4651,8 @@ If we would've written `yield`, `return yield`, or `return`, the entire generato ```javascript const person = { - name: 'Lydia Hallie', - hobbies: ['coding'], + name: "Lydia Hallie", + hobbies: ["coding"], }; function addHobby(hobby, hobbies = person.hobbies) { @@ -4656,9 +4660,9 @@ function addHobby(hobby, hobbies = person.hobbies) { return hobbies; } -addHobby('running', []); -addHobby('dancing'); -addHobby('baking', person.hobbies); +addHobby("running", []); +addHobby("dancing"); +addHobby("baking", person.hobbies); console.log(person.hobbies); ``` @@ -4727,11 +4731,11 @@ We create the variable `pet` which is an instance of the `Flamingo` class. When ###### 143. Which of the options result(s) in an error? ```javascript -const emojis = ['🎄', '🎅đŸŧ', '🎁', '⭐']; +const emojis = ["🎄", "🎅đŸŧ", "🎁", "⭐"]; -/* 1 */ emojis.push('đŸĻŒ'); +/* 1 */ emojis.push("đŸĻŒ"); /* 2 */ emojis.splice(0, 2); -/* 3 */ emojis = [...emojis, 'đŸĨ‚']; +/* 3 */ emojis = [...emojis, "đŸĨ‚"]; /* 4 */ emojis.length = 0; ``` @@ -4817,9 +4821,9 @@ function getFruit(fruits) { console.log(fruits?.[1]?.[1]); } -getFruit([['🍊', '🍌'], ['🍍']]); +getFruit([["🍊", "🍌"], ["🍍"]]); getFruit(); -getFruit([['🍍'], ['🍊', '🍌']]); +getFruit([["🍍"], ["🍊", "🍌"]]); ``` - A: `null`, `undefined`, 🍌 @@ -4885,8 +4889,8 @@ We set the variable `calc` equal to a new instance of the `Calc` class. Then, we ```javascript const user = { - email: 'e@mail.com', - password: '12345', + email: "e@mail.com", + password: "12345", }; const updateUser = ({ email, password }) => { @@ -4901,7 +4905,7 @@ const updateUser = ({ email, password }) => { return user; }; -const updatedUser = updateUser({ email: 'new@email.com' }); +const updatedUser = updateUser({ email: "new@email.com" }); console.log(updatedUser === user); ``` @@ -4926,11 +4930,11 @@ The `updateUser` function updates the values of the `email` and `password` prope ###### 149. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const fruit = ['🍌', '🍊', '🍎']; +const fruit = ["🍌", "🍊", "🍎"]; fruit.slice(0, 1); fruit.splice(0, 1); -fruit.unshift('🍇'); +fruit.unshift("🍇"); console.log(fruit); ``` @@ -4958,11 +4962,11 @@ At last, we invoke the `unshift` method on the `fruit` array, which modifies the ```javascript const animals = {}; -let dog = { emoji: 'đŸļ' }; -let cat = { emoji: '🐈' }; +let dog = { emoji: "đŸļ" }; +let cat = { emoji: "🐈" }; -animals[dog] = { ...dog, name: 'Mara' }; -animals[cat] = { ...cat, name: 'Sara' }; +animals[dog] = { ...dog, name: "Mara" }; +animals[cat] = { ...cat, name: "Sara" }; console.log(animals[dog]); ``` @@ -4994,13 +4998,13 @@ Logging `animals[dog]`, or actually `animals["[object Object]"]` since convertin ```javascript const user = { - email: 'my@email.com', + email: "my@email.com", updateEmail: (email) => { this.email = email; }, }; -user.updateEmail('new@email.com'); +user.updateEmail("new@email.com"); console.log(user.email); ``` @@ -5024,10 +5028,10 @@ The `updateEmail` function is an arrow function, and is not bound to the `user` ###### 152. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -const promise1 = Promise.resolve('First'); -const promise2 = Promise.resolve('Second'); -const promise3 = Promise.reject('Third'); -const promise4 = Promise.resolve('Fourth'); +const promise1 = Promise.resolve("First"); +const promise2 = Promise.resolve("Second"); +const promise3 = Promise.reject("Third"); +const promise4 = Promise.resolve("Fourth"); const runPromises = async () => { const res1 = await Promise.all([promise1, promise2]); @@ -5060,8 +5064,8 @@ The `Promise.all` method runs the passed promises in parallel. If one promise fa ###### 153. What should the value of `method` be to log `{ name: "Lydia", age: 22 }`? ```javascript -const keys = ['name', 'age']; -const values = ['Lydia', 22]; +const keys = ["name", "age"]; +const values = ["Lydia", 22]; const method = /* ?? */ @@ -5096,7 +5100,7 @@ This creates an array of subarrays containing the correct keys and values, which ```javascript const createMember = ({ email, address = {} }) => { const validEmail = /.+\@.+\..+/.test(email); - if (!validEmail) throw new Error('Valid email pls'); + if (!validEmail) throw new Error("Valid email pls"); return { email, @@ -5104,7 +5108,7 @@ const createMember = ({ email, address = {} }) => { }; }; -const member = createMember({ email: 'my@email.com' }); +const member = createMember({ email: "my@email.com" }); console.log(member); ``` @@ -5128,10 +5132,10 @@ The default value of `address` is an empty object `{}`. When we set the variable ###### 155. āĻāϟāĻžāϰ āφāωāϟāĻĒ⧁āϟ āϕ⧋āύāϟāĻž? ```javascript -let randomValue = { name: 'Lydia' }; +let randomValue = { name: "Lydia" }; randomValue = 23; -if (!typeof randomValue === 'string') { +if (!typeof randomValue === "string") { console.log("It's not a string!"); } else { console.log("Yay it's a string!"); From fe2dddb69328d08555952d4cbeb765ebb65a8237 Mon Sep 17 00:00:00 2001 From: iamsaief Date: Tue, 23 Jul 2024 02:43:11 +0600 Subject: [PATCH 11/12] added translation till 150 --- bn-BD/README_bn-BD.md | 92 +++++++++++++++++++++---------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/bn-BD/README_bn-BD.md b/bn-BD/README_bn-BD.md index af201342..4ac18dad 100644 --- a/bn-BD/README_bn-BD.md +++ b/bn-BD/README_bn-BD.md @@ -4379,7 +4379,7 @@ funcTwo(); --- -###### 134. How can we invoke `sum` in `sum.js` from `index.js?` +###### 134. āĻ•āĻŋāĻ­āĻžāĻŦ⧇ āφāĻŽāϰāĻž `sum.js` āĻāϰ `sum` āϕ⧇ `index.js` āĻĨ⧇āϕ⧇ āĻ•āϞ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ? ```javascript // sum.js @@ -4401,7 +4401,7 @@ import * as sum from "./sum"; #### āωāĻ¤ā§āϤāϰ: C -With the asterisk `*`, we import all exported values from that file, both default and named. If we had the following file: +āĻāĻ–āĻžāύ⧇ āĻāĻ¸ā§āĻŸā§‡āϰāĻŋāĻ¸ā§āĻ• `*` āĻĻāĻŋā§Ÿā§‡, āφāĻŽāϰāĻž āĻ“āχ āĻĢāĻžāχāϞ⧇āϰ āϏāĻ•āϞ āĻāĻ•ā§āϏāĻĒā§‹āĻ°ā§āϟ āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞ⧋āϕ⧇ āχāĻŽā§āĻĒā§‹āĻ°ā§āϟ āĻ•āϰ⧇āĻ›āĻŋ, _āĻĄāĻŋāĻĢāĻ˛ā§āϟ_ āĻ“ _āύ⧇āĻŽāĻĄ_ āĻĻ⧁āĻŸā§‹āχāĨ¤ āϝāĻĻāĻŋ āφāĻŽāĻžāĻĻ⧇āϰ āύāĻŋāĻšā§‡ āωāĻ˛ā§āϞ⧇āĻ–āĻŋāϤ āĻĢāĻžāχāϞ āĻĨāĻžāĻ•āϤāσ ```javascript // info.js @@ -4414,7 +4414,7 @@ import * as info from "./info"; console.log(info); ``` -The following would get logged: +āϤāĻŦ⧇ āύāĻŋāĻšā§‡ āωāĻ˛ā§āϞ⧇āĻ–āĻŋāϤāĻ­āĻžāĻŦ⧇ āϞāĻ— āĻšāϤāσ ```javascript { @@ -4424,13 +4424,13 @@ The following would get logged: } ``` -For the `sum` example, it means that the imported value `sum` looks like this: +`sum` āωāĻĻāĻžāĻšāϰāϪ⧇āϰ āĻŦ⧇āϞāĻžā§Ÿ, āĻāϟāĻž āĻŦā§‹āĻāĻžā§Ÿ āϝ⧇ āχāĻŽā§āĻĒā§‹āĻ°ā§āϟ āĻ•āϰāĻž `sum` āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻāϰāĻ•āĻŽ āĻĻ⧇āĻ–āĻžāĻŦ⧇āσ ```javascript { default: function sum(x) { return x + x } } ``` -We can invoke this function, by calling `sum.default` +āφāĻŽāϰāĻž āĻāχ āĻĢāĻžāύāĻ‚āĻļāύāϟāĻŋāϕ⧇ āϚāĻžāϞāĻžāϤ⧇ āĻĒāĻžāϰāĻŋ, `sum.default` āĻ•āϞ āĻ•āϰāĻžāϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡āĨ¤

@@ -4461,20 +4461,20 @@ person.name; #### āωāĻ¤ā§āϤāϰ: C -With a Proxy object, we can add custom behavior to an object that we pass to it as the second argument. In this case, we pass the `handler` object which contains two properties: `set` and `get`. `set` gets invoked whenever we _set_ property values, and `get` gets invoked whenever we _get_ (access) property values. +Proxy āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻĻāĻŋā§Ÿā§‡, āφāĻŽāϰāĻž āϕ⧋āύ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āĻ•āĻžāĻ¸ā§āϟāĻŽ āĻ…āϚāĻžāϰāύ āϝ⧁āĻ•ā§āϤ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ āϝ⧇āϟāĻžāϕ⧇ ⧍⧟ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āĻšāĻŋāϏ⧇āĻŦ⧇ āĻĒāĻžāϏ āĻ•āϰāĻŋāĨ¤ āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, `handler` āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻĒāĻžāϏ āĻ•āϰ⧇āĻ›āĻŋ āϝ⧇āϟāĻžā§Ÿ āĻĻ⧁āϟāĻŋ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϏ āφāϛ⧇āσ `set` āĻāĻŦāĻ‚ `get`āĨ¤ `set` āĻ•āϞ āĻšā§Ÿ āϝāĻ–āύāĻŋ āφāĻŽāϰāĻž āϕ⧋āύ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁ _āϏ⧇āϟ_ āĻ•āϰāĻŋ, āĻāĻŦāĻ‚ `get` āĻ•āϞ āĻšā§Ÿ āϝāĻ–āύāĻŋ āφāĻŽāϰāĻž āϕ⧋āύ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁ _āĻĒ⧇āϤ⧇_ āϚāĻžāχ (āĻāĻ•ā§āϏ⧇āϏ āĻ•āϰāĻŋ)āĨ¤ -The first argument is an empty object `{}`, which is the value of `person`. To this object, the custom behavior specified in the `handler` object gets added. If we add a property to the `person` object, `set` will get invoked. If we access a property on the `person` object, `get` gets invoked. +āĻĒā§āϰāĻĨāĻŽ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟāϟāĻŋ āĻšāϞ⧋ āĻāĻ•āϟāĻŋ āĻĢāĻžāρāĻ•āĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ `{}`, āϝ⧇āϟāĻž `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻ­ā§āϝāĻžāϞ⧁āĨ¤ āĻāχ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡, `handler` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āĻŦāĻ°ā§āύ⧀āϤ āĻ•āĻžāĻ¸ā§āϟāĻŽ āφāϚāϰāĻŖāϗ⧁āϞ⧋ āϝ⧁āĻ•ā§āϤ āĻšā§Ÿā§‡āϛ⧇āĨ¤ āϝāĻĻāĻŋ āφāĻŽāϰāĻž `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϕ⧋āύ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻŋ, `set` āĻ•āϞ āĻšāĻŦ⧇āĨ¤ āϝāĻĻāĻŋ āφāĻŽāϰāĻž `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϕ⧋āύ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āĻāĻ•ā§āϏ⧇āϏ āĻ•āϰāĻŋ, `get` āĻ•āϞ āĻšāĻŦ⧇āĨ¤ -First, we added a new property `name` to the proxy object (`person.name = "Lydia"`). `set` gets invoked, and logs `"Added a new property!"`. +āĻĒā§āϰāĻĨāĻŽā§‡, āφāĻŽāϰāĻž āĻĒā§āϰāĻ•ā§āϏāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āύāϤ⧁āύ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ `name` āϝ⧁āĻ•ā§āϤ āĻ•āϰ⧇āĻ›āĻŋ (`person.name = "Lydia"`)āĨ¤ `set` āĻ•āϞ āĻšāĻŦ⧇, āĻāĻŦāĻ‚ āϞāĻ— āĻ•āϰ⧇ `"Added a new property!"`āĨ¤ -Then, we access a property value on the proxy object, and the `get` property on the handler object is invoked. `"Accessed a property!"` gets logged. +āĻāϰāĻĒāϰ⧇, āφāĻŽāϰāĻž āĻĒā§āϰāĻ•ā§āϏāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻāĻ•āϟāĻŋ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āĻāĻ•ā§āϏ⧇āϏ āĻ•āϰāĻ›āĻŋ, āĻāĻŦāĻ‚ āĻšā§āϝāĻžāĻ¨ā§āĻĄāϞāĻžāϰ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ `get` āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āĻ•āϞ āĻšā§ŸāĨ¤ `"Accessed a property!"` āϞāĻ— āĻšā§ŸāĨ¤

--- -###### 136. Which of the following will modify the `person` object? +###### 136. āύāĻŋāĻšā§‡āϰ āϕ⧋āύāϟāĻŋ `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāĻŦ⧇? ```javascript const person = { name: "Lydia Hallie" }; @@ -4492,16 +4492,16 @@ Object.seal(person); #### āωāĻ¤ā§āϤāϰ: A -With `Object.seal` we can prevent new properties from being _added_, or existing properties to be _removed_. +`Object.seal` āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇, āφāĻŽāϰāĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āϕ⧋āύ āύāϤ⧁āύ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ _āϝ⧁āĻ•ā§āϤ_ āĻ•āϰāĻžā§Ÿ āĻŦāĻžāϧāĻž āĻĻāĻŋāϤ⧇ āĻĒāĻžāϰ⧇, āĻ…āĻĨāĻŦāĻž āϕ⧋āύ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ _āĻŽā§āϛ⧇_ āĻĢ⧇āϞāĻžā§Ÿ āĻŦāĻžāϧāĻž āĻĻāĻŋāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ -However, you can still modify the value of existing properties. +āĻ•āĻŋāĻ¨ā§āϤ⧁, āφāĻĒāύāĻŋ āĻāĻ–āύ⧋ āĻŦāĻŋāĻĻā§āϝāĻŽāĻžāύ āϕ⧋āύ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŦ⧇āύāĨ¤ āϝ⧇āĻŽāύ, `person.name = "Evan Bacon"`āĨ¤

--- -###### 137. Which of the following will modify the `person` object? +###### 137. āύāĻŋāĻšā§‡āϰ āϕ⧋āύāϟāĻŋ `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāĻŦ⧇? ```javascript const person = { @@ -4524,9 +4524,9 @@ Object.freeze(person); #### āωāĻ¤ā§āϤāϰ: C -The `Object.freeze` method _freezes_ an object. No properties can be added, modified, or removed. +`Object.freeze` āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇, āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ _āϏāĻ‚āϰāĻ•ā§āώāĻŋāϤ_ āĻŦāĻž _āĻĢā§āϰāĻŋāϜ_ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āύāĨ¤ āĻ…āĻ°ā§āĻĨāĻžā§Ž āϕ⧋āύ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻž, āĻŽā§āϛ⧇ āĻĢ⧇āϞāĻž, āĻŦāĻž āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāĻž āϝāĻžāĻŦ⧇ āύāĻžāĨ¤ -However, it only _shallowly_ freezes the object, meaning that only _direct_ properties on the object are frozen. If the property is another object, like `address` in this case, the properties on that object aren't frozen, and can be modified. +āĻ•āĻŋāĻ¨ā§āϤ⧁, āĻāϟāĻž āϕ⧇āĻŦāϞ _āĻ…āĻ—āĻ­ā§€āϰāĻ­āĻžāĻŦ⧇_ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āĻĢā§āϰāĻŋāϜ āĻ•āϰ⧇, āĻŽāĻžāύ⧇ āĻšāϞ⧋ āϝ⧇ āĻāϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϕ⧇āĻŦāϞ _āĻĒā§āϰāϤāĻ•ā§āĻˇā§āϝ_ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϏ (first level) āϗ⧁āϞ⧋āϕ⧇ āĻĢā§āϰāĻŋāϜ āĻ•āϰ⧇, āϝ⧇āĻŽāύ āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ `address`, āĻāχ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϏāϗ⧁āϞ⧋ āĻĢā§āϰāĻŋāϜ āĻšā§ŸāύāĻŋ, āĻāĻŦāĻ‚ ⧇āĻĻ⧇āϰ āĻĒā§āϰāχāĻŦāĻ°ā§āϤāύ āĻ•āϰāĻž āϝāĻžāĻŦ⧇āĨ¤ āϝ⧇āĻŽāύ, `person.address.street = "101 Main St"`āĨ¤

@@ -4556,9 +4556,9 @@ myFunc(3); #### āωāĻ¤ā§āϤāϰ: A -First, we invoked `myFunc()` without passing any arguments. Since we didn't pass arguments, `num` and `value` got their default values: num is `2`, and `value` is the returned value of the function `add`. To the `add` function, we pass `num` as an argument, which had the value of `2`. `add` returns `4`, which is the value of `value`. +āĻĒā§āϰāĻĨāĻŽā§‡, āφāĻŽāϰāĻž āϕ⧋āύ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āĻ›āĻžā§œāĻžāχ `myFunc()` āϕ⧇ āĻ•āϞ āĻ•āϰ⧇āĻ›āĻŋāĨ¤ āϝ⧇āĻšā§‡āϤ⧁ āϕ⧋ āύāĻžāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āĻĒāĻžāϏ āĻ•āϰāĻŋāύāĻŋ, `num` āĻ“ `value` āϤāĻžāĻĻ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁ āĻšāĻŋāϏ⧇āĻŦ⧇ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻ­ā§āϝāĻžāϞ⧁āχ āĻĒāĻžāĻšā§āϛ⧇āσ `num` āĻšāϞ `2`, āĻāĻŦāĻ‚ `value` āĻšāϞ `add` āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ­ā§āϝāĻžāϞ⧁āĨ¤ `add` āĻĢāĻžāĻ‚āĻļāύ⧇ āφāĻŽāϰāĻž āĻāĻ•āϟāĻŋ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āĻĒāĻžāϏ āĻ•āϰ⧇āĻ›āĻŋ `num`, āϝ⧇āϟāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻšāϞ `2`āĨ¤ `add` āĻĢāĻžāĻ‚āĻļāύ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `4`, āĻāϟāĻžāχ āĻšāϞ⧋ `value`-āϰ āĻ­ā§āϝāĻžāϞ⧁āĨ¤ -Then, we invoked `myFunc(3)` and passed the value `3` as the value for the argument `num`. We didn't pass an argument for `value`. Since we didn't pass a value for the `value` argument, it got the default value: the returned value of the `add` function. To `add`, we pass `num`, which has the value of `3`. `add` returns `6`, which is the value of `value`. +āĻĒāϰāĻŦāĻ°ā§āϤ⧀āϤ⧇, āφāĻŽāϰāĻž `myFunc(3)` āĻ•āϰāĻ›āĻŋ, āĻāĻ–āĻžāύ⧇ `3` āϕ⧇ āĻĒāĻžāϏ āĻ•āϰāĻ›āĻŋ `num` āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āĻ­ā§āϝāĻžāϞ⧁ āĻšāĻŋāϏ⧇āĻŦ⧇āĨ¤ āφāĻŽāϰāĻž `value` āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āϕ⧋āύ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāϏ āĻ•āϰāĻŋāύāĻŋ, āĻāϟāĻž āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāĻšā§āϛ⧇āσ `add` āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ­ā§āϝāĻžāϞ⧁āĨ¤ `add` āĻĢāĻžāĻ‚āĻļāύ⧇ āφāĻŽāϰāĻž `num` āĻĒāĻžāϏ āĻ•āϰ⧇āĻ›āĻŋ, āϝ⧇āϟāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁ `3`āĨ¤ `add` āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `6`, āĻāϟāĻžāχ āĻšāϞ⧋ `value`-āϰ āĻ­ā§āϝāĻžāϞ⧁āĨ¤

@@ -4596,14 +4596,14 @@ console.log(counter.#number); #### āωāĻ¤ā§āϤāϰ: D -In ES2020, we can add private variables in classes by using the `#`. We cannot access these variables outside of the class. When we try to log `counter.#number`, a SyntaxError gets thrown: we cannot access it outside the `Counter` class! +āχāĻāϏ⧍ā§Ļ⧍ā§Ļ āĻ, āĻ•ā§āϞāĻžāϏ⧇āϰ āϭ⧇āϤāϰ āφāĻŽāĻžāϰāĻž āĻĒā§āϰāĻžāχāϭ⧇āϟ āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞ āϝ⧁āĻ•ā§āϤ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ `#` āĻŦā§āϝāĻžāĻŦāĻšāĻžāϰ āĻ•āϰ⧇āĨ¤ āφāĻŽāϰāĻž āĻāχ āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞāϗ⧁āϞ⧋āϕ⧇ āĻ•ā§āϞāĻžāϏ⧇āϰ āĻŦāĻžāχāϰ⧇ āĻĨ⧇āϕ⧇ āĻāĻ•ā§āϏ⧇āϏ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ āύāĻžāĨ¤ āϝāĻ–āύ `counter.#number` āϕ⧇ āϞāĻ— āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāĻž āĻšā§Ÿ, SyntaxError āĻ›ā§‹ā§œāĻž āĻšā§Ÿāσ we cannot access it outside the `Counter` class!

--- -###### 140. What's missing? +###### 140. āĻāĻ–āĻžāύ⧇ āĻŽāĻŋāϏāĻŋāĻ‚ āĻ…āĻ‚āĻļ⧇ āĻ•āĻŋ āĻšāĻŦ⧇? ```javascript const teams = [ @@ -4638,9 +4638,9 @@ obj.next(); // { value: "Lisa", done: false } #### āωāĻ¤ā§āϤāϰ: B -In order to iterate over the `members` in each element in the `teams` array, we need to pass `teams[i].members` to the `getMembers` generator function. The generator function returns a generator object. In order to iterate over each element in this generator object, we need to use `yield*`. +`teams` āĻ…ā§āϝāĻžāϰ⧇āϰ āĻĒā§āϰāϤāĻŋāϟāĻŋ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āϜāĻ¨ā§āϝ `members` āĻāϰ āωāĻĒāϰ āϞ⧁āĻĒ āϚāĻžāϞāĻžāϤ⧇ āĻšāϞ⧇, `getMembers` āĻœā§‡āύāĻžāϰ⧇āϟāϰ āĻĢāĻžāĻ‚āĻļāύ⧇ `teams[i].members` āϕ⧇ āĻĒāĻžāϏ āĻ•āϰāϤ⧇ āĻšāĻŦ⧇āĨ¤ āĻœā§‡āύāĻžāϰ⧇āϟāϰ āĻĢāĻžāĻ‚āĻļāύ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ āĻāĻ•āϟāĻŋ āĻœā§‡āύāĻžāϰ⧇āϟāϰ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāĨ¤ āĻœā§‡āύāĻžāϰ⧇āϟāϰ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻĒā§āϰāϤāĻŋāϟāĻŋ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āωāĻĒāϰ āϞ⧁āĻĒ āϚāĻžāϞāĻžāύ⧋āĻ¨ā§āϰ āϜāĻ¨ā§āϝ, āφāĻŽāĻžāĻĻ⧇āϰāϕ⧇ `yield*` āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāϤ⧇ āĻšāĻŦ⧇āĨ¤ -If we would've written `yield`, `return yield`, or `return`, the entire generator function would've gotten returned the first time we called the `next` method. +āϝāĻĻāĻŋ āφāĻŽāϰāĻž `yield`, `return yield`, āĻŦāĻž `return` āϞāĻŋāĻ–āϤāĻžāĻŽ, āϏāĻŽā§āĻĒ⧁āĻ°ā§āύ āĻœā§‡āύ⧇āϰāĻžāϟāϰ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻĒ⧇āϤāĻžāĻŽ āĻĒā§āϰāĻĨāĻŽāĻŦāĻžāϰ `next` āĻŽā§‡āĻĨāĻĄ āĻ•āϰāĻžāϰ āĻĒāϰ⧇āĨ¤

@@ -4677,15 +4677,13 @@ console.log(person.hobbies); #### āωāĻ¤ā§āϤāϰ: C -The `addHobby` function receives two arguments, `hobby` and `hobbies` with the default value of the `hobbies` array on the `person` object. +`addHobby` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ ⧍āϟāĻŋ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āĻ—ā§āϰāĻšāĻŖ āĻ•āϰ⧇, `hobby` āĻ“ `hobbies` - āϝāĻžāϰ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻ­ā§āϝāĻžāϞ⧁ āĻšāϞ⧋ `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ `hobbies` āĻ…ā§āϝāĻžāϰ⧇āĨ¤ -First, we invoke the `addHobby` function, and pass `"running"` as the value for `hobby` and an empty array as the value for `hobbies`. Since we pass an empty array as the value for `hobbies`, `"running"` gets added to this empty array. +āĻĒā§āϰāĻĨāĻŽā§‡, āφāĻŽāϰāĻž `addHobby` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻ•āϞ āĻ•āϰāĻ›āĻŋ āĻāĻŦāĻ‚ `hobby`-āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāϏ āĻ•āϰāĻ›āĻŋ `"running"` āĻāĻŦāĻ‚ `hobbies`-āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāϏ āĻ•āϰāĻ›āĻŋ āĻāĻ•āϟāĻŋ āĻĢāĻžāρāĻ•āĻž āĻ…ā§āϝāĻžāϰ⧇āĨ¤ āϝ⧇āĻšā§‡āϤ⧁ āĻāĻ•āϟāĻŋ āĻĢāĻžāρāĻ•āĻž āĻ…ā§āϝāĻžāϰ⧇ āĻĒāĻžāϏ āĻ•āϰāĻ›āĻŋ `hobbies`-āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻšāĻŋāϏ⧇āĻŦ⧇, `"running"` āϝ⧁āĻ•ā§āϤ āĻšāĻšā§āϛ⧇ āĻāχ āĻĢāĻžāρāĻ•āĻž āĻ…ā§āϝāĻžāϰ⧇āϤ⧇āĨ¤ -Then, we invoke the `addHobby` function, and pass `"dancing"` as the value for `hobby`. We didn't pass a value for `hobbies`, so it gets the default value, the `hobbies` property on the `person` object. We push the hobby `dancing` to the `person.hobbies` array. +āĻāϰāĻĒāϰ⧇, āφāĻŽāϰāĻž `addHobby` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻ•āϞ āĻ•āϰāĻ›āĻŋ āĻāĻŦāĻ‚ `hobby`-āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāϏ āĻ•āϰāĻ›āĻŋ `"dancing"`āĨ¤ `hobbies` āĻāϰ āϜāĻ¨ā§āϝ āφāĻŽāϰāĻž āϕ⧋āύ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāϏ āĻ•āϰāĻŋāύāĻŋ, āϤāĻžāχ āĻāϟāĻžāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻšā§Ÿ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋāχ, āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻšāϞ⧋ `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ `hobbies` āĻ…ā§āϝāĻžāϰ⧇āĨ¤ āφāĻŽāϰāĻž `person.hobbies` āĻ…ā§āϝāĻžāϰ⧇āϤ⧇ `"dancing"` āϝ⧁āĻ•ā§āϤ (āĻĒ⧁āĻļ) āĻ•āϰāĻ›āĻŋāĨ¤ -Last, we invoke the `addHobby` function, and pass `"baking"` as the value for `hobby`, and the `person.hobbies` array as the value for `hobbies`. We push the hobby `baking` to the `person.hobbies` array. - -After pushing `dancing` and `baking`, the value of `person.hobbies` is `["coding", "dancing", "baking"]` +āϏāĻ°ā§āĻļ⧇āώ⧇, āφāĻŽāϰāĻž `addHobby` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ āĻ•āϞ āĻ•āϰāĻ›āĻŋ āĻāĻŦāĻ‚ `hobby`-āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāϏ āĻ•āϰāĻ›āĻŋ `"baking"`, āĻāĻŦāĻ‚ `hobbies`-āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāϏ āĻ•āϰāĻ›āĻŋ `person.hobbies` āĻ…ā§āϝāĻžāϰ⧇āϟāĻŋāĨ¤ āφāĻŽāϰāĻž `person.hobbies` āĻ…ā§āϝāĻžāϰ⧇āϤ⧇ `"baking"` āϝ⧁āĻ•ā§āϤ (āĻĒ⧁āĻļ) āĻ•āϰāĻ›āĻŋāĨ¤

@@ -4721,14 +4719,14 @@ const pet = new Flamingo(); #### āωāĻ¤ā§āϤāϰ: B -We create the variable `pet` which is an instance of the `Flamingo` class. When we instantiate this instance, the `constructor` on `Flamingo` gets called. First, `"I'm pink. 🌸"` gets logged, after which we call `super()`. `super()` calls the constructor of the parent class, `Bird`. The constructor in `Bird` gets called, and logs `"I'm a bird. đŸĻĸ"`. +āφāĻŽāϰāĻž `pet` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞāϟāĻŋ āϤ⧈āϰāĻŋ āĻ•āϰ⧇āĻ›āĻŋ āϝ⧇āϟāĻž `Flamingo` āĻ•ā§āϞāĻžāϏ⧇āϰ āĻāĻ•āϟāĻŋ āχāĻ¨ā§āϏāĻŸā§āϝāĻžāĻ¨ā§āϏāĨ¤ āϝāĻ–āύ āφāĻŽāϰāĻž āĻāχ āχāĻ¨ā§āϏāĻŸā§āϝāĻžāĻ¨ā§āϏāϟāĻŋāϕ⧇ āχāĻ¨ā§āϏāĻŸā§āϝāĻžāύāĻļāĻŋā§Ÿā§‡āϟ (`new Flamingo()`) āĻ•āϰāĻŋ, `Flamingo` āĻ•ā§āϞāĻžāϏ⧇āϰ āĻ•āĻ¨ā§āϏāĻŸā§āϰāĻžāĻ•ā§āϟāϰ āĻ•āϞ āĻšā§ŸāĨ¤ āĻĒā§āϰāĻĨāĻŽā§‡, `"I'm pink. 🌸"` āϞāĻ— āĻšā§Ÿ, āĻāϰāĻĒāϰ⧇ āφāĻŽāϰāĻž `super()` āĻ•āϞ āĻ•āϰāĻŋāĨ¤ `super()` āĻĒā§āϝāĻžāϰ⧇āĻ¨ā§āϟ āĻ•ā§āϞāĻžāϏ `Bird`-āĻāϰ āĻ•āĻ¨ā§āϏāĻŸā§āϰāĻžāĻ•ā§āϟāϰāϕ⧇ āĻ•āϞ āĻ•āϰ⧇āĨ¤ `Bird` āĻ•ā§āϞāĻžāϏ⧇āϰ āĻ•āĻ¨ā§āϏāĻŸā§āϰāĻžāĻ•ā§āϟāϰ āĻ•āϞ āĻšā§Ÿ āĻāĻŦāĻ‚ āϞāĻ— āĻ•āϰ⧇ `"I'm a bird. đŸĻĸ"`āĨ¤

--- -###### 143. Which of the options result(s) in an error? +###### 143. āϕ⧋āύ āĻ…āĻĒāĻļāύāϟāĻŋ āĻāϰāϰ āϰ⧇āϜāĻžāĻ˛ā§āϟ āĻĻā§‡ā§Ÿ? ```javascript const emojis = ["🎄", "🎅đŸŧ", "🎁", "⭐"]; @@ -4749,14 +4747,14 @@ const emojis = ["🎄", "🎅đŸŧ", "🎁", "⭐"]; #### āωāĻ¤ā§āϤāϰ: D -The `const` keyword simply means we cannot _redeclare_ the value of that variable, it's _read-only_. However, the value itself isn't immutable. The properties on the `emojis` array can be modified, for example by pushing new values, splicing them, or setting the length of the array to 0. +`const` āĻ•āĻŋāĻ“ā§ŸāĻžāĻ°ā§āĻĄ āĻĻāĻŋā§Ÿā§‡ āĻ¨ā§‡ā§ŸāĻž āϕ⧋āύ āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇ āφāĻŽāϰāĻž _āϰāĻŋāĻĄāĻŋāĻ•ā§āĻ˛ā§‡ā§ŸāĻžāϰ_ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŦ āύāĻž (`emojis = [...emojis, "đŸĨ‚"]`), āĻāϟāĻž āϕ⧇āĻŦāϞ _āϰāĻŋāĻĄ-āĻ…āύāϞāĻŋ_āĨ¤ āĻ•āĻŋāĻ¨ā§āϤ⧁ āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞ⧋ āύāĻŋāĻœā§‡āϰāĻž āĻ…āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāĻ¨ā§€ā§Ÿ āύ⧟āĨ¤ āĻ…āĻ°ā§āĻĨāĻžā§Ž `emojis` āĻ…ā§āϝāĻžāϰ⧇āϰ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟāϗ⧁āϞ⧋āϕ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāĻž āϝāĻžāĻŦ⧇, āωāĻĻāĻžāĻšāϰāĻŖāĻ¸ā§āĻŦāϰ⧂āĻĒ, āύāϤ⧁āύ āĻ­ā§āϝāĻžāϞ⧁ āĻĒ⧁āĻļ (āϝ⧁āĻ•ā§āϤ) āĻ•āϰāĻž (`emojis.push("đŸĻŒ")`), āĻ¸ā§āĻĒā§āϞāĻžāχāϏ āĻ•āϰāĻž (āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āχāύāĻĄā§‡āĻ•ā§āϏ⧇ āĻ­ā§āϝāĻžāϞ⧁ āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻž) (`emojis.splice(0, 2)`), āĻŦāĻž āĻ…ā§āϝāĻžāϰ⧇āϰ āϞ⧇āĻ¨ā§āĻĨāϕ⧇ āϜāĻŋāϰ⧋ (`emojis.length = 0`) āϏ⧇āϟ āĻ•āϰāĻžāĨ¤

--- -###### 144. What do we need to add to the `person` object to get `["Lydia Hallie", 21]` as the output of `[...person]`? +###### 144. `[...person]` āĻāϰ āφāωāϟāĻĒ⧁āϟ `["Lydia Hallie", 21]` āĻĒ⧇āϤ⧇ āĻšāϞ⧇ `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āφāĻŽāĻžāĻĻ⧇āϰ āĻ•āĻŋ āϝ⧁āĻ•ā§āϤ āĻ•āϰāϤ⧇ āĻšāĻŦ⧇? ```javascript const person = { @@ -4777,7 +4775,7 @@ const person = { #### āωāĻ¤ā§āϤāϰ: C -Objects aren't iterable by default. An iterable is an iterable if the iterator protocol is present. We can add this manually by adding the iterator symbol `[Symbol.iterator]`, which has to return a generator object, for example by making it a generator function `*[Symbol.iterator]() {}`. This generator function has to yield the `Object.values` of the `person` object if we want it to return the array `["Lydia Hallie", 21]`: `yield* Object.values(this)`. +āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻĄāĻŋāĻĢāĻ˛ā§āϟāĻ­āĻžāĻŦ⧇ āχāϟāĻžāϰ⧇āĻŦāϞ āύ⧟āĨ¤ āĻāĻ•āϟāĻŋ āχāϟāĻžāϰ⧇āĻŦāϞ āχāϟāĻžāϰ⧇āĻŦāϞ āĻšā§Ÿ āϝāĻĻāĻŋ āχāϟāĻžāϰ⧇āϟāϰ āĻĒā§āϰ⧋āĻŸā§‹āĻ•āϞ āĻĨāĻžāϕ⧇āĨ¤ āφāĻŽāϰāĻž āĻāϟāĻž āύāĻŋāϜāĻžāϰāĻž āϝ⧁āĻ•ā§āϤ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ āχāϟāĻžāϰ⧇āϟāϰ āϏāĻŋāĻŽā§āĻŦāϞ `[Symbol.iterator]` āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻžāϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡, āϝ⧇āϟāĻžāϕ⧇ āĻāĻ•āϟāĻŋ āĻœā§‡āύāĻžāϰ⧇āϟāϰ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϤ⧇ āĻšāĻŦ⧇, āωāĻĻāĻžāĻšāϰāĻŖāĻ¸ā§āĻŦāϰ⧂āĻĒ āĻāϟāĻžāϕ⧇ āĻāĻ•āϟāĻŋ āĻœā§‡āύāĻžāϰ⧇āϟāϰ āĻĢāĻžāĻ‚āĻļāύ `*[Symbol.iterator]() {}` āĻ•āϰāĻžāϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡āĨ¤ āĻāχ āĻœā§‡āύāĻžāϰ⧇āϟāϰ āĻĢāĻžāĻ‚āĻļāύ `person` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ `Object.values` āϕ⧇ āχāĻ˛ā§āĻĄ āĻ•āϰāϤ⧇ āĻšāĻŦ⧇ āϝāĻĻāĻŋ āφāĻŽāϰāĻž āϚāĻžāχ āĻāϟāĻž āĻ…ā§āϝāĻžāϰ⧇āϟāĻŋ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻŦ⧇āσ `["Lydia Hallie", 21]`: `yield* Object.values(this)`

@@ -4807,7 +4805,7 @@ console.log(count); #### āωāĻ¤ā§āϤāϰ: C -The `if` condition within the `forEach` loop checks whether the value of `num` is truthy or falsy. Since the first number in the `nums` array is `0`, a falsy value, the `if` statement's code block won't be executed. `count` only gets incremented for the other 3 numbers in the `nums` array, `1`, `2` and `3`. Since `count` gets incremented by `1` 3 times, the value of `count` is `3`. +`forEach` āϞ⧁āĻĒ⧇āϰ `if` āĻļāĻ°ā§āϤāϟāĻŋ āĻšā§‡āĻ• āĻ•āϰāϛ⧇ `num` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻŸā§āϰ⧁āĻĨāĻŋ āĻŦāĻž āĻĢāϞāϏāĻŋ āĻ•āĻŋāύāĻžāĨ¤ āϝ⧇āĻšā§‡āϤ⧁ `num` āĻ…ā§āϝāĻžāϰ⧇āϰ ā§§āĻŽ āύāĻžāĻŽā§āĻŦāĻžāϰāϟāĻŋ `0`, āĻāĻ•āϟāĻŋ āĻĢāϞāϏāĻŋ āĻ­ā§āϝāĻžāϞ⧁, āϤāĻžāχ `if` āĻ¸ā§āĻŸā§‡āϟāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āϕ⧋āĻĄ āĻŦā§āϞāĻ•āϟāĻŋ āϚāϞāĻŦ⧇ āύāĻžāĨ¤ `count` āϕ⧇āĻŦāϞ āĻ…āĻ¨ā§āϝ ā§ŠāϟāĻŋ āύāĻžāĻŽā§āĻŦāĻžāϰ⧇āϰ āϜāĻ¨ā§āϝ āĻŦ⧃āĻĻā§āϧāĻŋ āĻĒāĻžāĻŦ⧇, `1`, `2` āĻ“ `3`āĨ¤ āϝ⧇āĻšā§‡āϤ⧁ `count` `1` āĻ•āϰ⧇ ā§ŠāĻŦāĻžāϰ āĻŦ⧃āĻĻā§āϧāĻŋ āĻĒāĻžā§Ÿ, `count` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻāĻ–āύ āĻšā§Ÿā§‡āϛ⧇ `3`āĨ¤

@@ -4836,13 +4834,13 @@ getFruit([["🍍"], ["🍊", "🍌"]]); #### āωāĻ¤ā§āϤāϰ: D -The `?` allows us to optionally access deeper nested properties within objects. We're trying to log the item on index `1` within the subarray that's on index `1` of the `fruits` array. If the subarray on index `1` in the `fruits` array doesn't exist, it'll simply return `undefined`. If the subarray on index `1` in the `fruits` array exists, but this subarray doesn't have an item on its `1` index, it'll also return `undefined`. +`?.` āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ āφāĻŽāϰāĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻĄāĻŋāĻĒāĻžāϰ āύ⧇āĻ¸ā§āĻŸā§‡āĻĄ āϕ⧋āύ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϕ⧇ āĻ…āĻĒāĻļāύāĻžāϞāĻŋ āĻāĻ•ā§āϏ⧇āϏ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ āφāĻŽāϰāĻž āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāĻ›āĻŋ āϏāĻžāĻŦ-āĻ…ā§āϝāĻžāϰ⧇āϰ āχāύāĻĄā§‡āĻ•ā§āϏ `1` āφāχāĻŸā§‡āĻŽāϟāĻŋāϕ⧇ āϞāĻ— āĻ•āϰāĻžāϰ āϝ⧇āϟāĻž `fruits` āĻ…ā§āϝāĻžāϰ⧇āϰ āχāύāĻĄā§‡āĻ•ā§āϏ `1` āĻ āĻ…āĻŦāĻ¸ā§āĻĨāĻŋāϤāĨ¤ āϝāĻĻāĻŋ `fruits` āĻ…ā§āϝāĻžāϰ⧇āϰ āχāύāĻĄā§‡āĻ•ā§āϏ `1` āĻ āϏāĻžāĻŦ-āĻ…ā§āϝāĻžāϰ⧇āϟāĻŋāϕ⧇ āĻĒāĻžāĻ“ā§ŸāĻž āύāĻž āϝāĻžā§Ÿ, āĻāϟāĻž `undefined` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻŦ⧇āĨ¤ āϝāĻĻāĻŋ `fruits` āĻ…ā§āϝāĻžāϰ⧇āϰ āχāύāĻĄā§‡āĻ•ā§āϏ `1` āĻ āϏāĻžāĻŦ-āĻ…ā§āϝāĻžāϰ⧇āϟāĻŋāϕ⧇ āĻĒāĻžāĻ“ā§ŸāĻž āϝāĻžā§Ÿ, āĻ•āĻŋāĻ¨ā§āϤ⧁ āϏāĻžāĻŦ-āĻ…ā§āϝāĻžāϰ⧇āϤ⧇ āχāύāĻĄā§‡āĻ•ā§āϏ `1` āφāχāĻŸā§‡āĻŽāϟāĻŋāϕ⧇ āĻĒāĻžāĻ“ā§ŸāĻž āύāĻž āϝāĻžā§Ÿ āϤāĻ–āύāĻ“ āĻāϟāĻž `undefined` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻŦ⧇āĨ¤ -First, we're trying to log the second item in the `['🍍']` subarray of `[['🍊', '🍌'], ['🍍']]`. This subarray only contains one item, which means there is no item on index `1`, and returns `undefined`. +āĻĒā§āϰāĻĨāĻŽā§‡, āφāĻŽāϰāĻž āϞāĻ— āĻ•āϰāĻžāϰ āĻšā§‡āĻˇā§āϟāĻž āĻ•āϰāĻ›āĻŋ `[['🍊', '🍌'], ['🍍']]`-āĻ…ā§āϝāĻžāϰ⧇āϟāĻŋāϰ āϏāĻžāĻŦ-āĻ…ā§āϝāĻžāϰ⧇ `['🍍']` āĻĨ⧇āϕ⧇ āĻĻā§āĻŦāĻŋāĻ¤ā§€ā§Ÿ āφāχāĻŸā§‡āĻŽāϟāĻŋāĨ¤ āĻāχ āϏāĻžāĻŦ-āĻ…ā§āϝāĻžāϰ⧇āϤ⧇ āϕ⧇āĻŦāϞ āĻāĻ•āϟāĻŋ āφāχāĻŸā§‡āĻŽāχ āφāϛ⧇, āϝāĻžāϰ āĻŽāĻžāύ⧇ āĻšāϞ āĻāϰ āχāύāĻĄā§‡āĻ•ā§āϏ `1`-āĻ āĻ•āĻŋāϛ⧁ āύ⧇āχ āϤāĻžāχ `undefined` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇āĨ¤ -Then, we're invoking the `getFruits` function without passing a value as an argument, which means that `fruits` has a value of `undefined` by default. Since we're conditionally chaining the item on index `1` of`fruits`, it returns `undefined` since this item on index `1` does not exist. +āĻāϰāĻĒāϰ, `getFruits` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋāϕ⧇ āĻ•āϞ āĻ•āϰ⧇āĻ›āĻŋ āϕ⧋āύ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āϟ āĻšāĻŋāϏ⧇āĻŦ⧇ āĻĒāĻžāϏ āύāĻž āĻ•āϰ⧇āχ, āϝāĻžāϰ āĻŽāĻžāύ⧇ āĻšā§Ÿ `fruits` āĻāϰ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāĻšā§āϛ⧇ `undefined`āĨ¤ āϝ⧇āĻšā§‡āϤ⧁, āφāĻŽāϰāĻž `fruits` āĻ…ā§āϝāĻžāϰ⧇āϰ āχāύāĻĄā§‡āĻ•ā§āϏ `1` āφāχāĻŸā§‡āĻŽāϕ⧇ āĻ•āĻ¨ā§āĻĄāĻŋāĻļāύāĻžāϞāĻŋ āĻšā§‡āχāύāĻŋāĻ‚ āĻ•āϰāĻ›āĻŋ, āĻāϟāĻž `undefined` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇ āĻ•āĻžāϰāύ āχāύāĻĄā§‡āĻ•ā§āϏ `1` āĻāϰ āφāχāĻŸā§‡āĻŽ āύ⧇āχāĨ¤ -Lastly, we're trying to log the second item in the `['🍊', '🍌']` subarray of `['🍍'], ['🍊', '🍌']`. The item on index `1` within this subarray is `🍌`, which gets logged. +āϏāĻ°ā§āĻŦāĻļ⧇āώ⧇, āφāĻŽāϰāĻž āĻšā§‡āĻˇā§āϟāĻž āϞāĻ— āĻ•āϰāĻžāϰ āĻ•āϰāĻ›āĻŋ `[["🍍"], ["🍊", "🍌"]]`-āĻ…ā§āϝāĻžāϰ⧇āϟāĻŋāϰ āϏāĻžāĻŦ-āĻ…ā§āϝāĻžāϰ⧇ `['🍊', '🍌']` āĻĨ⧇āϕ⧇ āĻĻā§āĻŦāĻŋāĻ¤ā§€ā§Ÿ āφāχāĻŸā§‡āĻŽāϟāĻŋāĨ¤ āϏāĻžāĻŦ-āĻ…ā§āϝāĻžāϰ⧇āϰ āχāύāĻĄā§‡āĻ•ā§āϏ `1` āĻāϰ āφāχāĻŸā§‡āĻŽāϟāĻŋ āĻšāϞ `🍌`, āĻāϟāĻŋāχ āϞāĻ— āĻšā§Ÿā§‡āϛ⧇āĨ¤

@@ -4878,7 +4876,7 @@ console.log(calc.count); #### āωāĻ¤ā§āϤāϰ: A -We set the variable `calc` equal to a new instance of the `Calc` class. Then, we instantiate a new instance of `Calc`, and invoke the `increase` method on this instance. Since the count property is within the constructor of the `Calc` class, the count property is not shared on the prototype of `Calc`. This means that the value of count has not been updated for the instance calc points to, count is still `0`. +āφāĻŽāϰāĻž `calc` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞāϕ⧇ āϏ⧇āϟ āĻ•āϰ⧇āĻ›āĻŋ `Calc` āĻ•ā§āϞāĻžāϏ⧇āϰ āύāϤ⧁āύ āχāĻ¨ā§āϏāĻŸā§āϝāĻžāĻ¨ā§āϏ⧇āϰ āϏāĻŽāĻžāύāĨ¤ āĻāϰāĻĒāϰ, āφāĻŽāϰāĻž `Calc` āĻ•ā§āϞāĻžāϏ⧇āϰ āύāϤ⧁āύ āĻāĻ•āϟāĻŋ āχāĻ¨ā§āϏāĻŸā§āϝāĻžāĻ¨ā§āϏāϕ⧇ āχāĻ¨ā§āϏāĻŸā§āϝāĻžāĻ¨ā§āϏāĻŋā§Ÿā§‡āϟ āĻ•āϰ⧇āĻ›āĻŋ, āĻāĻŦāĻ‚ āĻāχ āχāĻ¨ā§āϏāĻŸā§āϝāĻžāĻ¨ā§āϏ āĻĻāĻŋā§Ÿā§‡ `increase` āĻŽā§‡āĻĨāĻĄ āĻ•āϞ āĻ•āϰ⧇āĻ›āĻŋāĨ¤ āϝ⧇āĻšā§‡āϤ⧁ `count` āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϟāĻŋ `Calc` āĻ•ā§āϞāĻžāϏ⧇āϰ āĻ•āĻ¨ā§āϏāĻŸā§āϰāĻžāĻ•ā§āϟāϰ⧇āϰ āϭ⧇āϤāϰ āφāϛ⧇, āϤāĻžāχ āĻāχ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϟāĻŋ `Calc` āĻ•ā§āϞāĻžāϏ⧇āϰ āĻĒā§āϰ⧋āĻŸā§‹āϟāĻžāχāĻĒ⧇ āĻļā§‡ā§ŸāĻžāϰ āĻšā§ŸāύāĻŋāĨ¤ āĻāϰ āĻŽāĻžāύ⧇ āĻšāϞ āϝ⧇ `count` āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋāϰ āϕ⧋āύ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻšā§ŸāύāĻŋ āύāϤ⧁āύ āχāĻ¨ā§āϏāĻŸā§āϝāĻžāĻ¨ā§āϏ āϝ⧇ `Calc` āĻ•ā§āϞāĻžāϏāϕ⧇ āĻĒā§Ÿā§‡āĻ¨ā§āϟ āĻ•āϰāϛ⧇ āϤāĻžāϰ āϜāĻ¨ā§āϝ, āϤāĻžāχ `count` āĻāĻ–āύ⧋ `0`āĨ¤

@@ -4920,7 +4918,7 @@ console.log(updatedUser === user); #### āωāĻ¤ā§āϤāϰ: B -The `updateUser` function updates the values of the `email` and `password` properties on user, if their values are passed to the function, after which the function returns the `user` object. The returned value of the `updateUser` function is the `user` object, which means that the value of updatedUser is a reference to the same `user` object that `user` points to. `updatedUser === user` equals `true`. +`updateUser` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ `user` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ `email` āĻ“ `password` āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇ āϝāĻĻāĻŋ āĻĢāĻžāĻ‚āĻļāύ⧇ āϤāĻžāĻĻ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁āϗ⧁āϞ⧋āϕ⧇ āĻĒāĻžāϏ āĻ•āϰāĻž āĻšā§Ÿ, āĻāϰāĻĒāϰ⧇ āĻĢāĻžāĻ‚āĻļāύāϟāĻŋ `user` āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϟāĻŋāϕ⧇ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āĨ¤ `updateUser` āĻĢāĻžāĻ‚āĻļāύāϟāĻŋāϰ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻšāϞ `user` āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ, āϝāĻžāϰ āĻŽāĻžāύ⧇ `updateUser` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻšāϞ āĻāĻ•āχ `user` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āϰ⧇āĻĢāĻžāϰ⧇āĻ¨ā§āϏ āϝ⧇āϟāĻž `user` āĻĒā§Ÿā§‡āĻ¨ā§āϟ āĻ•āϰāϛ⧇āĨ¤ āĻĢāϞ⧇ `updatedUser === user` āϏāĻŽāĻžāύ āĻšāĻšā§āϛ⧇ `true`āĨ¤

@@ -4949,9 +4947,11 @@ console.log(fruit); #### āωāĻ¤ā§āϤāϰ: C -First, we invoke the `slice` method on the fruit array. The slice method does not modify the original array, but returns the value that it sliced off the array: the banana emoji. -Then, we invoke the `splice` method on the fruit array. The splice method does modify the original array, which means that the fruit array now consists of `['🍊', '🍎']`. -At last, we invoke the `unshift` method on the `fruit` array, which modifies the original array by adding the provided value, ‘🍇’ in this case, as the first element in the array. The fruit array now consists of `['🍇', '🍊', '🍎']`. +āĻĒā§āϰāĻĨāĻŽā§‡, āφāĻŽāϰāĻž `fruit` āĻ…ā§āϝāĻžāϰ⧇āϤ⧇ `slice` āĻŽā§‡āĻĨāĻĄ āĻ•āϞ āĻ•āϰ⧇āĻ›āĻŋāĨ¤ `slice` āĻŽā§‡āĻĨāĻĄ āφāϏāϞ āĻ…ā§āϝāĻžāϰ⧇āϕ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇ āύāĻž, āĻ•āĻŋāĻ¨ā§āϤ⧁ āĻ…ā§āϝāĻžāϰ⧇ āĻĨ⧇āϕ⧇ āĻ–āĻ¨ā§āĻĄāĻŋāϤ (āĻ¸ā§āϞāĻžāχāϏ) āĻ•āϰ⧇ āφāύāĻž āφāχāĻŸā§‡āĻŽ/āϗ⧁āϞ⧋ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇āσ āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āĻ•āϞāĻžāϰ āχāĻŽāϜāĻŋ `'🍌'`āĨ¤ + +āĻāϰāĻĒāϰ⧇, āφāĻŽāϰāĻž `fruit` āĻ…ā§āϝāĻžāϰ⧇āϤ⧇ `splice` āĻŽā§‡āĻĨāĻĄ āĻ•āϞ āĻ•āϰ⧇āĻ›āĻŋāĨ¤ `splice` āĻŽā§‡āĻĨāĻĄ āφāϏāϞ āĻ…ā§āϝāĻžāϰ⧇āϕ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇, āϝāĻžāϰ āĻŽāĻžāύ⧇ āĻšāϞ, āĻāĻ–āύ `fruit` āĻ…ā§āϝāĻžāϰ⧇āϤ⧇ āĻ…āĻŦāĻļāĻŋāĻˇā§āϟ āφāϛ⧇ `['🍊', '🍎']`āĨ¤ + +āϏāĻ°ā§āĻŦāĻļ⧇āώ⧇, āφāĻŽāϰāĻž `fruit` āĻ…ā§āϝāĻžāϰ⧇āϤ⧇ `unshift` āĻŽā§‡āĻĨāĻĄ āĻ•āϞ āĻ•āϰ⧇āĻ›āĻŋāĨ¤ `unshift` āĻŽā§‡āĻĨāĻĄā§‡ āĻĒāĻžāϏ āĻ•āϰāĻž āĻ­ā§āϝāĻžāϞ⧁/āϗ⧁āϞ⧋āϕ⧇ āĻ…ā§āϝāĻžāϰ⧇āϤ⧇ āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻžāϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡ āϏ⧇ āφāϏāϞ āĻ…ā§āϝāĻžāϰ⧇āϕ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇, āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ āĻ…ā§āϝāĻžāϰ⧇āϰ āĻĒā§āϰāĻĨāĻŽ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟ āĻšāĻŋāϏ⧇āĻŦ⧇āĨ¤ āϤāĻžāχ āĻāĻ–āύ `fruit` āĻ…ā§āϝāĻžāϰ⧇āϟāĻŋāϤ⧇ āĻĨāĻžāĻ•āϛ⧇ `['🍇', '🍊', '🍎']`āĨ¤

@@ -4981,13 +4981,13 @@ console.log(animals[dog]); #### āωāĻ¤ā§āϤāϰ: B -Object keys are converted to strings. +āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ āĻ•āĻŋ-āϗ⧁āϞ⧋āϕ⧇ āϜāĻžāĻ­āĻžāĻ¸ā§āĻ•ā§āϰāĻŋāĻĒā§āϟ āχāĻžā§āϜāĻŋāύ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚-āĻ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇āĨ¤ -Since the value of `dog` is an object, `animals[dog]` actually means that we’re creating a new property called `"[object Object]"` equal to the new object. `animals["[object Object]"]` is now equal to `{ emoji: "đŸļ", name: "Mara"}`. +āϝ⧇āĻšā§‡āϤ⧁ `dog` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ, `animals[dog]` āĻāϰ āĻŽāĻžāύ⧇ āφāĻŽāϰāĻž āφāϏāϞ⧇ āύāϤ⧁āύ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āϏāĻŽāĻžāύ āϏ⧇āϟ āĻ•āϰāĻ›āĻŋ `"[object Object]"` āύāĻžāĻŽā§‡āϰ āύāϤ⧁āύ āĻāĻ•āϟāĻŋ āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāĨ¤ āĻĢāϞ⧇ āĻāĻ–āύ `animals["[object Object]"]` āĻāϰ āϏāĻŽāĻžāύ āĻšāϞ⧋ `{ emoji: "đŸļ", name: "Mara"}`āĨ¤ -`cat` is also an object, which means that `animals[cat]` actually means that we’re overwriting the value of `animals["[object Object]"]` with the new cat properties. +`cat`-āĻ“ āĻāĻ•āϟāĻŋ āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ, āϝāĻžāϰ āĻŽāĻžāύ⧇ āĻšāϞ⧋ `animals[cat]` āφāϏāϞ⧇ `animals["[object Object]"]` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇ āĻ“āĻ­āĻžāϰāϰāĻžāχāĻĄ āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇ āύāϤ⧁āύ cat āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋ āĻĻāĻŋā§Ÿā§‡ āĻ…āĻ°ā§āĻĨāĻžā§Ž `animals["[object Object]"]` āϏāĻŽāĻžāύ āĻāĻ–āύ `{ emoji: "🐈", name: "Sara" }`āĨ¤ -Logging `animals[dog]`, or actually `animals["[object Object]"]` since converting the `dog` object to a string results `"[object Object]"`, returns the `{ emoji: "🐈", name: "Sara" }`. +`animals[dog]` āϕ⧇ āϞāĻ— āĻ•āϰāĻž, āφāϏāϞ⧇ `animals["[object Object]"]` āϕ⧇āχ āϞāĻ— āĻ•āϰāĻž āϝ⧇āĻšā§‡āϤ⧁ `dog` āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāϞ⧇ āĻĒāĻžāĻ“ā§ŸāĻž āϝāĻžā§Ÿ `"[object Object]"` āϝ⧇āϟāĻž āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ `{ emoji: "🐈", name: "Sara" }`āĨ¤

From 142843e48cbabbce7eb7f3afbf4cb3b4f5bd3469 Mon Sep 17 00:00:00 2001 From: iamsaief Date: Tue, 23 Jul 2024 06:12:37 +0600 Subject: [PATCH 12/12] =?UTF-8?q?added=20translation=20till=20155,=20the?= =?UTF-8?q?=20end=20=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bn-BD/README_bn-BD.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bn-BD/README_bn-BD.md b/bn-BD/README_bn-BD.md index 4ac18dad..b170d6e9 100644 --- a/bn-BD/README_bn-BD.md +++ b/bn-BD/README_bn-BD.md @@ -441,7 +441,7 @@ console.log(sarah); --- -###### 13. What are the three phases of event propagation? +###### 13. āχāϭ⧇āĻ¨ā§āϟ āĻĒā§āϰ⧋āĻĒāĻžāϗ⧇āĻļāύ⧇āϰ ā§ŠāϟāĻŋ āϧāĻžāĻĒ āĻ•āĻŋ āĻ•āĻŋ? - A: Target > Capturing > Bubbling - B: Bubbling > Target > Capturing @@ -1373,7 +1373,7 @@ console.log(gen.next().value); --- -###### 45. What does this return? +###### 45. āĻāϟāĻž āĻ•āĻŋ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇? ```javascript const firstPromise = new Promise((res, rej) => { @@ -5018,7 +5018,7 @@ console.log(user.email); #### āωāĻ¤ā§āϤāϰ: A -The `updateEmail` function is an arrow function, and is not bound to the `user` object. This means that the `this` keyword is not referring to the `user` object, but refers to the global scope in this case. The value of `email` within the `user` object does not get updated. When logging the value of `user.email`, the original value of `my@email.com` gets returned. +āĻāĻ–āĻžāύ⧇ `updateEmail` āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧋ āĻĢāĻžāĻ‚āĻļāύ, āĻāĻŦāĻ‚ āĻāϰ āĻ¸ā§āϕ⧋āĻĒ `user` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āĻŦāĻžāĻ§ā§āϝ āύ⧟āĨ¤ āĻāϰ āĻŽāĻžāύ⧇ āĻšāϞ⧋ āϝ⧇ `this` āϕ⧀āĻ“ā§ŸāĻžāĻ°ā§āĻĄāϟāĻŋ `user` āĻ…āĻŦāĻœā§‡āĻ•ā§āϟāϕ⧇ āϰ⧇āĻĢāĻžāϰ āĻ•āϰāϛ⧇ āύāĻž, āĻŦāϰāĻ‚ āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ āĻ—ā§āϞ⧋āĻŦāĻžāϞ āĻ¸ā§āϕ⧋āĻĒāϕ⧇ āϰ⧇āĻĢāĻžāϰ āĻ•āϰāϛ⧇āĨ¤ `user` āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡āϰ `email` āĻĒā§āϰ⧋āĻĒāĻžāĻ°ā§āϟāĻŋāϰ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻšāĻšā§āϛ⧇ āύāĻžāĨ¤ āĻĢāϞ⧇ āϝāĻ–āύ `user.email`-āĻāϰ āĻ­ā§āϝāĻžāϞ⧁āϕ⧇ āϞāĻ— āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇, āφāϏāϞ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋāχ-`my@email.com` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻšā§Ÿā§‡āϛ⧇āĨ¤

@@ -5054,14 +5054,14 @@ runPromises() #### āωāĻ¤ā§āϤāϰ: D -The `Promise.all` method runs the passed promises in parallel. If one promise fails, the `Promise.all` method _rejects_ with the value of the rejected promise. In this case, `promise3` is rejected with the value `"Third"`. We’re catching the rejected value in the chained `catch` method on the `runPromises` invocation to catch any errors within the `runPromises` function. Only `"Third"` gets logged, since `promise3` is rejected with this value. +`Promise.all` āĻŽā§‡āĻĨāĻĄāϟāĻŋ āĻĒāĻžāϏ āĻ•āϰāĻž āϏāĻ•āϞ āĻĒā§āϰāĻŽāĻŋāϏāϗ⧁āϞ⧋āϕ⧇ āϏāĻŽāĻžāĻ¨ā§āϤāϰāĻžāϞāĻ­āĻžāĻŦ⧇/āĻāĻ•āχ āϏāĻžāĻĨ⧇ āϰāĻžāύ āĻ•āϰ⧇āĨ¤ āϝāĻĻāĻŋ āĻāĻ•āϟāĻž āĻĒā§āϰāĻŽāĻŋāϏ āĻĢ⧇āχāϞ āĻ•āϰ⧇, `Promise.all` āĻŽā§‡āĻĨāĻĄ āϰāĻŋāĻœā§‡āĻ•ā§āϟ āĻ•āϰāĻž āĻĒā§āϰāĻŽāĻŋāϏ⧇āϰ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻĻāĻŋā§Ÿā§‡ _āϰāĻŋāĻœā§‡āĻ•ā§āϟ_ āĻ•āϰāĻŦ⧇āĨ¤ āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, `promise3` āϰāĻŋāĻœā§‡āĻ•ā§āϟ āĻšā§Ÿā§‡āϛ⧇ `"Third"` āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻĻāĻŋā§Ÿā§‡āĨ¤ āφāĻŽāϰāĻž āĻāχ āϰāĻŋāĻœā§‡āĻ•ā§āϟ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋāχ āĻ•ā§āϝāĻžāϚ āĻ•āϰāĻ›āĻŋ āĻšā§‡āχāύ `.catch` āĻŽā§‡āĻĨāĻĄā§‡ āϝāĻ–āύ `runPromises` āϚāϞāĻžāϰ āϏāĻŽā§Ÿ āĻāχ āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āϕ⧋āύ āĻāϰāϰ āĻ•ā§āϝāĻžāϚ āĻ•āϰāĻ›āĻŋāĨ¤ āϕ⧇āĻŦāϞ `"Third"`-āχ āϞāĻ— āĻšā§Ÿā§‡āϛ⧇, āϝ⧇āĻšā§‡āϤ⧁ `promise3` āϰāĻŋāĻœā§‡āĻ•ā§āϟ āĻšā§Ÿā§‡āϛ⧇ `"Third"` āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻĻāĻŋā§Ÿā§‡āĨ¤

--- -###### 153. What should the value of `method` be to log `{ name: "Lydia", age: 22 }`? +###### 153. `{ name: "Lydia", age: 22 }` āϞāĻ— āĻ•āϰāĻž āϜāĻ¨ā§āϝ `method` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻ•āĻŋ āĻšāĻ“ā§ŸāĻž āωāϚāĻŋā§Ž? ```javascript const keys = ["name", "age"]; @@ -5086,9 +5086,9 @@ const method = #### āωāĻ¤ā§āϤāϰ: C -The `fromEntries` method turns a 2d array into an object. The first element in each subarray will be the key, and the second element in each subarray will be the value. In this case, we’re mapping over the `keys` array, which returns an array that the first element is the item on the key array on the current index, and the second element is the item of the values array on the current index. +`fromEntries` āĻŽā§‡āĻĨāĻĄāϟāĻŋ āĻāĻ•āϟāĻŋ 2D āĻ…ā§āϝāĻžāϰ⧇āϕ⧇ āĻ…āĻŦāĻœā§‡āĻ•ā§āĻŸā§‡ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇āĨ¤ āĻĒā§āϰāϤāĻŋāϟāĻŋ āϏāĻžāĻŦ-āĻ…ā§āϝāĻžāϰ⧇āϰ ā§§āĻŽ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟāϟāĻŋ āĻšāĻŦ⧇ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻ•āĻŋ āĻāĻŦāĻ‚ ⧍⧟ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟāϟāĻŋ āĻšāĻŦ⧇ āĻāχ āĻ•āĻŋ-āĻāϰ āĻ­ā§āϝāĻžāϞ⧁āĨ¤ āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, āφāĻŽāϰāĻž `keys` āĻ…ā§āϝāĻžāϰ⧇āϰ āωāĻĒāϰ āĻŽā§āϝāĻžāĻĒ āϚāĻžāϞāĻžāĻšā§āĻ›āĻŋ, āϝ⧇āϟāĻž āĻāĻŽāύ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇ āϝāĻžāϰ ā§§āĻŽ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟāϟāĻŋ āĻšā§Ÿ āĻŦāĻ°ā§āϤāĻŽāĻžāύ āχāύāĻĄā§‡āĻ•ā§āϏ⧇āϰ āϜāĻ¨ā§āϝ āĻ•āĻŋ-āĻ…ā§āϝāĻžāϰ⧇āϰ āφāχāĻŸā§‡āĻŽ, āĻāĻŦāĻ‚ ⧍⧟ āĻāϞāĻŋāĻŽā§‡āĻ¨ā§āϟāϟāĻŋ āĻšā§Ÿ āĻŦāĻ°ā§āϤāĻŽāĻžāύ āχāύāĻĄā§‡āĻ•ā§āϏ⧇āϰ āϜāĻ¨ā§āϝ āĻ­ā§āϝāĻžāϞ⧁-āĻ…ā§āϝāĻžāϰ⧇āϰ āφāχāĻŸā§‡āĻŽāĨ¤ -This creates an array of subarrays containing the correct keys and values, which results in `{ name: "Lydia", age: 22 }` +āĻāϟāĻž āϏāĻžāĻŦ-āĻ…ā§āϝāĻžāϰ⧇āϗ⧁āϞ⧋āϰ āĻāĻ•āϟāĻŋ āĻ…ā§āϝāĻžāϰ⧇ āϤ⧈āϰāĻŋ āĻ•āϰ⧇ āϝ⧇āϟāĻžāϤ⧇ āϏāĻ āĻŋāĻ• āĻ•āĻŋ-āĻ­ā§āϝāĻžāϞ⧁ āϗ⧁āϞ⧋ āĻĨāĻžāϕ⧇, āĻāϟāĻžāϰāχ āĻĢāϞāĻžāĻĢāϞ āĻšā§Ÿā§‡āϛ⧇ `{ name: "Lydia", age: 22 }`

@@ -5122,7 +5122,7 @@ console.log(member); #### āωāĻ¤ā§āϤāϰ: C -The default value of `address` is an empty object `{}`. When we set the variable `member` equal to the object returned by the `createMember` function, we didn't pass a value for the address, which means that the value of the address is the default empty object `{}`. An empty object is a truthy value, which means that the condition of the `address ? address : null` conditional returns `true`. The value of the address is the empty object `{}`. +āĻāĻ–āĻžāύ⧇ `address` āĻāϰ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻ­ā§āϝāĻžāϞ⧁ āĻāĻ•āϟāĻŋ āĻĢāĻžāρāĻ•āĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ `{}`āĨ¤ āϝāĻ–āύ āφāĻŽāϰāĻž `member` āĻ­ā§āϝāĻžāϰāĻŋā§Ÿā§‡āĻŦāϞāϕ⧇ āϏ⧇āϟ āĻ•āϰāĻ›āĻŋ `createMember` āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ­ā§āϝāĻžāϞ⧁āϰ āϏāĻŽāĻžāύ, āφāĻŽāϰāĻž address āĻāϰ āϕ⧋āύ āĻ­ā§āϝāĻžāϞ⧁ āĻĒāĻžāϏ āĻ•āϰāĻŋāύāĻŋ, āĻāϰ āĻŽāĻžāύ⧇ āĻšāϞ⧋ āϝ⧇ `address` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻĨāĻžāĻ•āϛ⧇ āϤāĻžāϰ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻ­ā§āϝāĻžāϞ⧁ āĻĢāĻžāρāĻ•āĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ `{}`āĨ¤ āφāϰ āĻĢāĻžāρāĻ•āĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ āĻāĻ•āϟāĻŋ āĻŸā§āϰ⧁āĻĨāĻŋ āĻ­ā§āϝāĻžāϞ⧁, āϝāĻžāϰ āĻŽāĻžāύ⧇ `address ? address : null`-āĻ•āĻ¨ā§āĻĄāĻŋāĻļāύāĻžāϞ āĻāϰ āĻļāĻ°ā§āϤāϟāĻŋ `true` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāϛ⧇āĨ¤ `address` āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻĢāĻžāρāĻ•āĻž āĻ…āĻŦāĻœā§‡āĻ•ā§āϟ `{}`, āĻĢāϞ⧇ `{ email: "my@email.com", address: {} }` āϞāĻ— āĻšā§Ÿā§‡āϛ⧇āĨ¤

@@ -5152,9 +5152,9 @@ if (!typeof randomValue === "string") { #### āωāĻ¤ā§āϤāϰ: B -The condition within the `if` statement checks whether the value of `!typeof randomValue` is equal to `"string"`. The `!` operator converts the value to a boolean value. If the value is truthy, the returned value will be `false`, if the value is falsy, the returned value will be `true`. In this case, the returned value of `typeof randomValue` is the truthy value `"number"`, meaning that the value of `!typeof randomValue` is the boolean value `false`. +āĻāĻ–āĻžāύ⧇ `if` āĻ¸ā§āĻŸā§‡āϟāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āĻļāĻ°ā§āϤāϟāĻŋ āĻšā§‡āĻ• āĻ•āϰāϛ⧇ `!typeof randomValue`-āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āϏāĻŽāĻžāύ `"string"` āĻšā§Ÿ āĻ•āĻŋāύāĻžāĨ¤ `!` āĻ…āĻĒāĻžāϰ⧇āϟāϰāϟāĻŋ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋāϕ⧇ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇ āĻāĻ•āϟāĻŋ āĻŦ⧁āϞāĻŋ⧟āĻžāύ āĻ­ā§āϝāĻžāϞ⧁āϤ⧇āĨ¤ āϝāĻĻāĻŋ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ _āĻŸā§āϰ⧁āĻĨāĻŋ_ āĻšā§Ÿ, āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ­ā§āϝāĻžāϞ⧁ āĻšāĻŦ⧇ `false`, āϝāĻĻāĻŋ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ _āĻĢāϞāϏāĻŋ_ āĻšā§Ÿ, āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ­ā§āϝāĻžāϞ⧁āϟāĻŋ āĻšāĻŦ⧇ `true`āĨ¤ āĻāĻ•ā§āώ⧇āĻ¤ā§āϰ⧇, `typeof randomValue`-āĻāϰ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ­ā§āϝāĻžāϞ⧁ āĻšā§Ÿ `"number"`-āĻāϰ āĻŸā§āϰ⧁āĻĨāĻŋ āĻ­ā§āϝāĻžāϞ⧁, āĻŽāĻžāύ⧇ āĻšāϞ⧋ āϝ⧇ `!typeof randomValue`-āĻāϰ āĻ­ā§āϝāĻžāϞ⧁ āĻšā§Ÿ āĻŦ⧁āϞāĻŋ⧟āĻžāύ `false` āĻ­ā§āϝāĻžāϞ⧁āĨ¤ -`!typeof randomValue === "string"` always returns false, since we're actually checking `false === "string"`. Since the condition returned `false`, the code block of the `else` statement gets run, and `Yay it's a string!` gets logged. +`!typeof randomValue === "string"` āϏāĻŦāϏāĻŽā§Ÿ `false` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇, āϝ⧇āĻšā§‡āϤ⧁ āφāĻŽāϰāĻž āφāϏāϞ⧇ āĻšā§‡āĻ• āĻ•āϰāĻ›āĻŋ `false === "string"` āĻ•āĻŋāύāĻžāĨ¤ āĻĢāϞ⧇ āĻļāĻ°ā§āϤāϟāĻŋ `false` āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰ⧇, `else` āĻ¸ā§āĻŸā§‡āϟāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āϕ⧋āĻĄ āĻŦā§āϞāĻ•āϟāĻŋ āϰāĻžāύ āĻšā§Ÿ, āĻāĻŦāĻ‚ `Yay it's a string!` āϞāĻ— āĻšā§ŸāĨ¤