๐๐ฒ๐'๐ ๐๐ป๐ฑ๐ฒ๐ฟ๐๐๐ฎ๐ป๐ฑ ๐ฎ๐ฏ๐ผ๐๐ ๐๐ฐ๐ฐ๐ถ๐ฑ๐ฒ๐ป๐๐ฎ๐น ๐๐น๐ผ๐ฏ๐ฎ๐น ๐ฉ๐ฎ๐ฟ๐ถ๐ฎ๐ฏ๐น๐ฒ ๐ถ๐ป ๐๐ฎ๐๐ฎ๐ฆ๐ฐ๐ฟ๐ถ๐ฝ๐
๐ณ๐๐ป๐ฐ๐๐ถ๐ผ๐ป ๐ณ๐ฟ๐ถ๐ฑ๐ฎ๐() { ๐น๐ฒ๐ ๐ฎ = ๐ฏ = ๐ฌ; }
๐ณ๐ฟ๐ถ๐ฑ๐ฎ๐();
console.log("a: ", a); // ๐ฅ๐ฒ๐ณ๐ฒ๐ฟ๐ฒ๐ป๐ฐ๐ฒ๐๐ฟ๐ฟ๐ผ๐ฟ: ๐ฎ ๐ถ๐ ๐ป๐ผ๐ ๐ฑ๐ฒ๐ณ๐ถ๐ป๐ฒ๐ฑ console.log("b: ", b); // ๐ฏ: ๐ฌ
๐ฆ๐ผ ๐๐ผ๐ ๐บ๐ถ๐ด๐ต๐ ๐ฏ๐ฒ ๐๐ต๐ถ๐ป๐ธ๐ถ๐ป๐ด ๐๐ต๐ ๐ผ๐ป ๐ฐ๐ผ๐ป๐๐ผ๐น๐ฒ.๐น๐ผ๐ด("๐ฏ: ", ๐ฏ) ๐ถ๐ ๐ถ๐ ๐ด๐ถ๐๐ถ๐ป๐ด "๐ฏ: ๐ฌ" ๐ถ๐ป๐๐๐ฒ๐ฎ๐ฑ ๐ผ๐ณ ๐ฎ ๐ฅ๐ฒ๐ณ๐ฒ๐ฟ๐ฒ๐ป๐ฐ๐ฒ๐๐ฟ๐ฟ๐ผ๐ฟโ
Let's see
This statement inside function friday()
let a = b = 0; can be break down into two statements, i.e.
b = 0 // global scope let a = b // friday() scope
๐๐ฒ๐ป๐ฐ๐ฒ, ๐ฎ ๐ถ๐ ๐ป๐ผ๐ ๐ฎ๐๐ฎ๐ถ๐น๐ฎ๐ฏ๐น๐ฒ ๐ถ๐ป ๐ด๐น๐ผ๐ฏ๐ฎ๐น ๐๐ฐ๐ผ๐ฝ๐ฒ ๐๐ต๐ถ๐น๐ฒ ๐ฏ ๐ถ๐ ๐ฎ๐๐ฎ๐ถ๐น๐ฎ๐ฏ๐น๐ฒ.
That's why on printing a and b in global scope b is printed but a says that it is not defined. ๐๐ป ๐ผ๐๐ต๐ฒ๐ฟ ๐๐ผ๐ฟ๐ฑ๐, ๐ฏ ๐ถ๐ ๐ฎ ๐ด๐น๐ผ๐ฏ๐ฎ๐น ๐๐ฎ๐ฟ๐ถ๐ฎ๐ฏ๐น๐ฒ ๐ฐ๐ฟ๐ฒ๐ฎ๐๐ฒ๐ฑ ๐ฎ๐ฐ๐ฐ๐ถ๐ฑ๐ฒ๐ป๐๐ฎ๐น๐น๐.
To ๐ฝ๐ฟ๐ฒ๐๐ฒ๐ป๐ your code from creating global variables accidentally, you can ๐๐๐ฒ ๐๐๐ฟ๐ถ๐ฐ๐ mode.