feat: Add JavaScript core exercises and solutions
- Implemented exercises for array high-order methods, memory and execution, switch statements, and final review. - Added starter and answer files for each exercise to facilitate learning. - Created a runner HTML file to execute JavaScript code and display console outputs. - Updated README files to include exercise objectives, tasks, and usage instructions.
This commit is contained in:
30
03-javascript-core/11-var-and-scope/README.md
Normal file
30
03-javascript-core/11-var-and-scope/README.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# 练习 11:var、let、const 与提升
|
||||
|
||||
## 目标
|
||||
|
||||
理解 `var`、`let`、`const` 的基本区别,尤其是作用域和提升差异。
|
||||
|
||||
## 你要练什么
|
||||
|
||||
- `var`
|
||||
- `let`
|
||||
- `const`
|
||||
- 变量提升
|
||||
- 块级作用域
|
||||
- 函数作用域
|
||||
|
||||
## 任务
|
||||
|
||||
请完成一个“作用域观察”脚本,要求:
|
||||
|
||||
- 观察 `var` 声明前为什么能访问到 `undefined`
|
||||
- 用 `var` 声明一个函数内部变量
|
||||
- 用 `let` 声明一个代码块内部变量
|
||||
- 在可访问的位置输出它们
|
||||
- 观察为什么 `var` 在块外还能访问,而 `let` 不行
|
||||
- 再写一段代码证明 `const` 不能被重新赋值
|
||||
|
||||
## 文件
|
||||
|
||||
- [starter.js](/Users/lijiaqing/home/wwwroot/front-end-example/03-javascript-core/11-var-and-scope/starter.js)
|
||||
- [answer.js](/Users/lijiaqing/home/wwwroot/front-end-example/03-javascript-core/11-var-and-scope/answer.js)
|
||||
Reference in New Issue
Block a user